make 2 pages
1st page is the form
[code] <?php
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
?>
<!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>Contact Page</title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div align="center" id="wrapper">
<?php include_once("template_header.php");?>
<div id="content">
<table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td width="32%" valign="top"><form method="post" action="contact2.php"> Email: <input name="email" type="text"><br> Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br> <input type="submit"> </form> </td>
<td width="35%" valign="top"></td>
<td width="33%" valign="top"></td>
</tr>
</table>
</div>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>[/code]
the 2nd page is the php script
<?php $to = "[email protected]"; $subject = "Contact Us"; $email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ;
if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?>
that’s how I did it but if you want it to redirect to thank you page do as sarthak patel did and change the print statment on the php script to
<?php $to = "[email protected]"; $subject = "Contact Us"; $email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ;
if($sent) {header("Location: thanks.html"); } else {header("Location: fail.html"); } ?>
I called the 1st page ‘contact.php’ and the 2nd page ‘contact2’