Skip to content Skip to sidebar Skip to footer

Php Contact Form Not Submitting

Hi I've previously used this very simple php contact script with success though when I've tried implementing it on a new HTML page with the form won't submit. Can anyone see any ob

Solution 1:

Try with

if ( !empty($_POST["email"]) )

However you can check, what is posted in that page using:

echo'<pre>';
var_dump( $_POST );

Solution 2:

Change your form.php as the following

<?phpif ($_POST["email"]<>'') { 
    $ToEmail = 'onjegolders@gmail.com'; 
    $EmailSubject = 'Site contact form '; 
    $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 = "Telephone: ".$_POST["tel"]."<br>";
    $MESSAGE_BODY = "Type: ".$_POST["type"]."<br>";
    $MESSAGE_BODY = "Subject: ".$_POST["subject"]."<br>";
    $MESSAGE_BODY = "Level: ".$_POST["level"]."<br>";
    $MESSAGE_BODY = "Hours required: ".$_POST["hours"]."<br>";
    $MESSAGE_BODY .= "Additional information: ".nl2br($_POST["info"])."<br>"; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) ordie ("Failure"); 

echo &lt;&lt;&lt;EXCERPT

<html>

    <h3>Thanks for your email</h3>
    <h4>I'll get back to you as soon as possible</h4>
    <a href="index.html"><p>Click here to go back to previous page</p></a>

</html>

EXCERPT;

} else { 


echo "<html>Sorry, this form didn't work</html>";

} 
?>

Solution 3:

in your

if ($_POST["email"] <> '') { 

change that into

if ($_POST["email"] != '') { 

Solution 4:

You should try this:

if(!empty($_POST["email"])){
  //your email preparation code
}

Insted of using this:

if($_POST["email" <> ''){
  //your email preparation code
}

The ! basically means not, so the !empty means not empty

Solution 5:

You could also just use:

if ($_POST["email"]) { 

This works much like the != "" or empty() check. PHP was incepted to handle forms well. And you can just let it probe incoming form fields. It uses some magic boolean conversion rules for strings, which most of the time will accomplish what you want.

Another advantage of this simpler style is that it eases debugging if you enable the E_ALL and E_NOTICE (=debug) error_reporting mode.

Post a Comment for "Php Contact Form Not Submitting"