Page 1 of 1

PHP Contact Form Not Posting

Posted: Fri Jul 17, 2009 10:19 pm
by Alpha_Link
I seem to be having an issue with a PHP contact form not posting. (To be specific, entering in data and clicking the submit button just refreshes the page.) I triple-checked the code myself and ran it through a syntax checker, but everything looks good. Perhaps I seem to be missing something that someone else can catch? Here is the code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MCSS Form</title>
<link href="form.css" rel="stylesheet" type="text/css" />
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<div align="center">
        <?php 
        if ($_POST["submit"]<>'') { 
            $ToEmail = 'matt@mattscss.com'; 
            $EmailSubject = 'MCSS Contact Request '; 
            $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 .= "Email: ".$_POST["email"]."<br>"; 
            $MESSAGE_BODY .= "Phone: ".$_POST["phone"]."<br>";
            $MESSAGE_BODY .= "Reason: ".nl2br($_POST["comment"])."<br>";
            mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
        ?>
        <img src="../images/thankyou.jpg" widtd="368" height="70" /><br />
        <p class="text">Your message was successfully submitted!<br />
        Expect to receive a response within 24 hours.</p>
        <?php
        } else { 
        ?>
   <form action="submit.php" method="POST">
    <table border="0" cellspacing="4" cellpadding="0">
  <tr>
    <td class="form_titles" scope="row">Full Name:</td>
    <td class="form_titles"><div align="left"><span id="full_name">
            <input type="text" width="185" name="Full Name" id="name" />
        <span class="textfieldRequiredMsg">Your full name is required.</span></span></div>
    </td>
  </tr>
  <tr>
    <td class="form_titles" scope="row">E-mail Address:</td>
    <td class="form_titles"><div align="left"><span id="e-mail">
            <input type="text" width="185" name="E-mail Address" id="email" />
        <span class="textfieldRequiredMsg">A valid e-mail address is required.</span></span></div>
    </td>
  </tr>
  <tr>
    <td class="form_titles" scope="row">Phone Number:</td>
    <td class="form_titles"><div align="left"><span id="phone#">
            <input type="text" width="185" name="Phone Number" id="phone" />
        <span class="textfieldRequiredMsg">A vaild phone number is required.</span></span></div>
    </td>
  </tr>
  <tr>
    <td class="form_titles" style="vertical-align:top" scope="row">Please describe why you<br /> are contacting us today:</td>
    <td class="form_titles" style="vertical-align:top"><div align="left"><span id="message">
            <textarea name="Type your message here." id="comment" cols="30" rows="8"></textarea>
        <span class="textareaRequiredMsg">A message is required.</span></span></div>
    </td>
  </tr>
</table><br />
 
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input name="Submit" type="submit" value="Submit" /></td>
    <td width="10"></td>
    <td><input name="Clear Fields" type="reset" value="Clear Fields" /></td>
  </tr>
</table>
 </form></div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("full_name");
var sprytextfield2 = new Spry.Widget.ValidationTextField("e-mail", "email");
var sprytextfield3 = new Spry.Widget.ValidationTextField("phone#", "phone_number");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("message");
//-->
</script>
<?php
};
?>
</body>
</html>

Re: PHP Contact Form Not Posting

Posted: Fri Jul 17, 2009 11:28 pm
by sanju
hi


use
$_POST["Submit"] instead of $_POST["submit"] ... the name field in form input tag is case sensitive you have given capital letter S in Submit in input filed and small letter in accepting section


Regards
Sanju

Re: PHP Contact Form Not Posting

Posted: Sat Jul 18, 2009 10:05 am
by Alpha_Link
Thanks, it's up and running! For the name="" tags on the form inputs, I thought it was just used as an alternate text and the PHP script would go by the ID of the form field.