Jump to content

Making A Contact Form Success Message In Php


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

Edited by SuperPaperSam
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...