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

my php contact form

  • k well i've just finished my portfolio site, and i have been doing tutorials so i can learn php and i followed it to the letter but for some reason it doens't send the e-mail to my inbox. the site link is www.stray-designs.com/contact.html


    on the contact page i have a regular contact form

    <form id=\"form1\" name=\"form1\" method=\"POST\" action=\"form_response.php\">
    <p>
    <label class=\"label\">Name: </label>
    <input type=\"text\" name=\"name\" id=\"name\" size=\"40\" />

    </p>
    <p>
    <label class=\"label\">E-mail: </label >
    <input type=\"text\" name=\"email\" id=\"email\" size=\"39\" />

    </p>
    <p>
    <label class=\"label\">
    Leave your comment here:
    </label>
    </p>
    <TEXTAREA NAME=\"comment\" id=\"comment\" ROWS=6 COLS=40> </TEXTAREA> <br /><br />

    <input type=\"submit\" src=\"images/button.png\" name=\"submit\" id=\"submit\" value=\"Submit\" />



    </form>


    and then in my php page form_response.php


    <?php

    $name = $_REQUEST['name'];
    $email = $_REQUEST['email'];
    $comment = $_REQUEST['comment'];


    $email_message = \"Name: {$name} and your email is {$email} and your comment is {$comment}.\";

    mail( \"stray22@hotmail.co.uk\",'Form Response ', \"$email\");
    header( \"Location: http://www.stray-designs.com/thanks.html\" );


    ?>



    its a simple bit of code but i haven't a clue why its not working. can anyone help out a pure noob at this?
  • Alright gangsta give this a whirl, and if that doesnt work make sure your server is properly configured to send mail.

    <html>
    <head>
    </head>
    <body>
    <form id=\"form1\" name=\"form1\" method=\"POST\" action=\"form_response.php\">
    <p>
    <label class=\"label\">Name: </label>
    <input type=\"text\" name=\"name\" id=\"name\" size=\"40\" />

    </p>
    <p>
    <label class=\"label\">E-mail: </label >
    <input type=\"text\" name=\"email\" id=\"email\" size=\"39\" />

    </p>
    <p>
    <label class=\"label\">
    Leave your comment here:
    </label>
    </p>
    <TEXTAREA NAME=\"comment\" id=\"comment\" ROWS=6 COLS=40> </TEXTAREA> <br /><br />

    <input type=\"submit\" src=\"images/button.png\" name=\"submit\" id=\"submit\" value=\"Submit\" />

    </form>
    </body>
    </html>


    <?php

    $name = $_POST['name'];
    $email = $_POST['email'];
    $comment = $_POST['comment'];



    mail( \"mdgrech@gmail.com\", $comment, $email);
    echo \"Mail Sent.\";



    ?>
  • it seems that the server is the problem gonna check it now to see if it supports it
  • are all those backslashes in your actual code? if so, why?