Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2011
    Location
    Essex, England
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Problems with PHP form submission

    Hi

    I have a form I have set up using php that should submit an email on completion. When I set it up and tested it on my own website it worked absolutely fine but now I have uploaded it to a different website it no longer sends the email even though I get no error messages. i have spoken to the hosting company who have advised Emails have to have a senders address specified in your code, the server will reject any other emails to prevent spam. But surely that's what this line of my code does:

    PHP Code:
    $mailheader "From: ".$_POST["email"]."\r\n"
    doesn't it?

    Can anyone help me please?

    Full code supplied below

    Thanks

    PHP Code:
    <?php
    session_start
    (); 

    include(
    'http://www.rework.co.uk/forms/securimage/securimage.php');
    $securimage = new Securimage();
    if(
    $securimage->check($_POST['captcha_code']) == false) {
        
    // The code was incorrect
        
    echo "The security code entered was incorrect.<br /><br />";
        echo 
    "Please click back and try again.";
        exit();
    }

    if(
    $_POST["email"] != '') { 
        
    $ToEmail '[myemailaddress]'
        
    $EmailSubject 'Online Course Enquiry'
        
    $mailheader "From: ".$_POST["email"]."\r\n"
        
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"
        
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"
        
    $MESSAGE_BODY "Name: ".$_POST["name"]."<br>"
        
    $MESSAGE_BODY .= "Job Title: ".$_POST["job_title"]."<br>"
        
    $MESSAGE_BODY .= "Company: ".$_POST["company"]."<br>";
        
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";  
        
    $MESSAGE_BODY .= "Address: ".nl2br($_POST["address"])."<br>";
        
    $MESSAGE_BODY .= "Telephone: ".$_POST["phone"]."<br>";  
        
    $MESSAGE_BODY .= "Course Title: ".$_POST["course_title"]."<br>";
        
    $MESSAGE_BODY .= "Course Date: ".$_POST["course_date"]."<br>";   
        
    mail($ToEmail$EmailSubject$MESSAGE_BODY$mailheader) or die ("Failure"); 
        
    header('Location:[url]http://www.rework.co.uk/trainingsche...ccess=1');[/url// Redirect on success
    } else {
            echo(
    'Your email address was left blank. Please click back and type your email address.');
            exit();
    }
    ?>
    Last edited by Inigoesdr; 11-13-2011 at 03:17 AM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,325
    Thanks
    23
    Thanked 615 Times in 614 Posts
    But surely that's what this line of my code does:

    <code>$mailheader = "From: ".$_POST["email"]."\r\n";</code>
    I don't think so. You didn't post the code that calls this page so I don't knoe for sure, but I don't know why you would send YOUR email address from another page when you can hard code it so easily.

    Replace ".$_POST["email"]." with YOUR return address. Also $ToEmail = '[myemailaddress]'; probably needs to be changed.

  • #3
    New Coder
    Join Date
    Oct 2011
    Location
    Essex, England
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi Sunfighter

    thanks for your response, sorry that wasn't clear it was my way of not posting my email address!

    $ToEmail = '[myemailaddress]'; does contain my actual email address in the real code instead of "myemailaddress" but I should also add it in to the line above, so it reads ".$_POST["jo@[domain].co.uk"]." is that what you're saying?

    I guess the biggest thing I don't get is why it works okay as it was on my webserver but not on the new webserver!
    Last edited by jofield; 11-13-2011 at 09:04 AM.

  • #4
    New Coder
    Join Date
    Oct 2011
    Location
    Essex, England
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    okay so with a little playing around I've managed to sort all my paths for the CAPTCHA and this is no longer causing an issue.

    I now get confirmation that my form has submitted successfully and that works fine. However, I still don't get the actual email confirmation. I get this fine when tested on my own webserver just not on the clients. The client's hosting company say this is because the sender's email address needs to be specified by surely that's what this line of my code does:
    <code>$mailheader = "From: ".$_POST["email"]."\r\n"; </code>

    Does anyone have any other suggestions??

    Many thanks for any assistance


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •