Jump to content

Making A Contact Form Success Message In Php


SuperPaperSam

Recommended Posts

I would like to show a message after someone sends me a email. Stating whether there email was sent or not. Right now they are sent to a new page.I don't want the page to reload. And if possible I want to pick where the text would show up.This is the PHP I'm using now.

<?php  		$emailsubject = 'Contact';		$webMaster = 'youwillnotsendmespam@blah.blah';  		$nameField = $_POST ['name'];		$emailField = $_POST ['email'];		$messageField = $_POST ['message'];  		$body = <<<EOD	<hr>	Name: $nameField <br>	Email: $emailField <br>	Message: $messageField <br>	<hr>	EOD;  		$headers = "From: $emailField\r\n";		$headers .= "Content-type: text/html\r\n";		$success = mail($webMaster, $emailsubject, $body, $headers);  		$theResults = <<<EOD	<html>	  <head>	  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">	  </head>	  <div>	  <div align="left">Thank you for contacting me!</div>	  </div>	  </body>	  </html> EOD;  echo "$theResults"  ?>

Would this code work without a reload? Or do I have to use AJAX?

<?php  		$emailsubject = 'Contact';		$webMaster = 'youwillnotsendmespam@blah.blah';  		$nameField = $_POST ['name'];		$emailField = $_POST ['email'];		$messageField = $_POST ['message'];</font>  	 $body = <<<EOD	<hr>	Name: $nameField <br>	Email: $emailField <br>	Message: $messageField <br>	<hr>	EOD;  		$headers = "From: $emailField\r\n";		$headers .= "Content-type: text/html\r\n";		$success = mail($webMaster, $emailsubject, $body, $headers);  	 if ($success)			echo "Your message has been sent. I will get back to you as soon as possible.";		   else			echo "There has been a error! Make sure you have a working internet connection and try again.";

Any help would be very helpful.Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...