views:

240

answers:

3

I have a contact form on a page that sends the details of the form to an email address. You can view it here, www.wonder.ie

The HTML for the form is the following:

<form id="form" name="form27" class="wufoo  page" enctype="multipart/form-data" method="post" action="mailer.php">  
    <ul>
        <li id="foli1">
            <label class="op" id="title1" for="Field1">Name</label>
            <div><input id="Field1" name="name" type="text" class="op required" value="" maxlength="255" tabindex="1" onkeyup="handleInput(this);" onchange="handleInput(this);" /></div>  
        </li>

        <li id="foli2">
        <label class="op" id="title2" for="Field2">Email</label>
            <div><input id="Field2" name="email" type="text" class="op required email" value="" maxlength="255" tabindex="2" onkeyup="handleInput(this);" onchange="handleInput(this);" /></div>
        </li>

        <li id="foli3">
            <label class="op" id="title3" for="Field3">Inquiry</label>
            <div><textarea id="Field3" name="message" class="op required" rows="10" cols="50" tabindex="3" onkeyup="handleInput(this);" onchange="handleInput(this);"></textarea></div>
        </li>
        </ul>  
        <input id="button" name="saveForm" class="btTxt submit" type="submit" value="Submit" />         
</form>

And for my PHP it is this:

<?php
if(isset($_POST['submit'])) {
$to = "[email protected]";
$subject = "Email from Wonder.ie";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>

Does everything look correct? I know I have the form names matched correctly with the PHP but I can't figure out why I'm not receiving the email you know - FYI the PHP on the site has a real email address, not [email protected]. Once I hit the submit button I am taken to mailer.php but I notice the echo "blarg!" so my guess is the email is not being sent.

Thank you!

+7  A: 

You should change

if(isset($_POST['submit'])) {

to

if(isset($_POST['saveForm'])) {
codeholic
This is 100% right; when you access variables in $_POST they are labled via the name attribute of the form element.
Erik
+2  A: 

Try changing

if(isset($_POST['submit'])) {

to

if(isset($_POST['saveForm'])) {

This is because $_POST looks for the name of a form input, not the type.

superUntitled
A: 

It worked! My goodness. Thank you so much :) Can't believe it was one little error. Go figure!

Liam
Glad to hear. Then you're welcome to accept my answer ;-)
codeholic