treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Help with Contact Form please

  • Hi, love your work, however, me being a designer and not a coder have a little help needed!
    I have uploaded your contact form, my host supports php and all that good stuff, yet I get an error on submitting the form.
    I am guessing I have set up the contactengine.php wrong, here is a link to the form:

    http://www.glass.netcom21.co.uk/contact2/index.html

    Here are the contents of my contactengine.php:

    <?php

    // CHANGE THE VARIABLES BELOW

    $EmailFrom = "info@northerncarglass.com";
    $EmailTo = "info@northerncarglass.com";
    $Subject = "Contact Form Submission";

    $Name = Trim(stripslashes($_POST['Name']));
    $Tel = Trim(stripslashes($_POST['Tel']));
    $Email = Trim(stripslashes($_POST['Email']));
    $Message = Trim(stripslashes($_POST['Message']));

    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Tel: ";
    $Body .= $Tel;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    // redirect to success page
    // CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    }
    ?>

    Any help greatly apreciated!
    Jim
  • I don't know, I couldn't see what your error was because of the custom error page - it looks like the error page that it briefly displays holds the answer though.
  • Yeah, I can't stop the redirect, not sure how...
    I managed to take a screenshot of it though, amazingly :)
  • OK, so I fixed part of the problem, I changed 'Tel' to 'City' and that cleared that up, so now I am just getting:
  • Update: OK, so it seems that the email adress I was using is blocked, I will contact their host and resolve that.