I have a page that contains a contact form that uses the following code for submission of the form.
Can you show me how to get the following messages to appear in a page that looks the same as the rest of the website instead of a white page with only these messages written:
“You didn’t fill in these required fields: Please returnto the previous page and try again”
“The e-mail you provided is not valid. Please return to the previous page and try again.”
“Thank you for your feedback. We will get back to you shortly.”
Here’s the PHP code:
[code=php]<?
// This is the beginning of the PHP code
$name = $_POST[‘name’];
$email = $_POST[’email’];
$comments = $_POST[‘comments’];
$error_msg = “”;
$msg = “”;
if(!$email){
$error_msg .= “Your email n”;
}
if($email){
if(!eregi(“^[a-zA-Z0-9_.-]+@[a-zA-Z0-9._-]+.[a-zA-Z]{2,4}”, $email)){
echo “n<br>The e-mail you provided is not valid. Please <a href=”javascript:history.back()”>return</a> to the previous page and try
again.n<br>”;
exit;
}
$msg .= “Email: t $email n”;
}
if($comments){
$msg .= “Comments: t $comments n”;
}
$sender_email=””;
if(!isset($name)){
if($name == “”){
$sender_name=”Web Visitor”;
}
}else{
$sender_name=$name;
}
if(!isset($email)){
if($email == “”){
$sender_email=”[email protected]”;
}
}else{
$sender_email=$email;
}
if($error_msg != “”){
echo “You didn’t fill in these required fields:<br>”
.nl2br($error_msg) .'<br>Please <a href=”javascript:history.back()”>return</a> to the previous page and try again.’;
exit;
}
$mailheaders = “MIME-Version: 1.0rn”;
$mailheaders .= “Content-type: text/plain; charset=iso-8859-1rn”;
$mailheaders .= “From: $sender_name <$sender_email>rn”;
$mailheaders .= “Reply-To: $sender_email <$sender_email>rn”;
mail(“[email protected]”,”Website Contact”,stripslashes($msg), $mailheaders);
echo “<html>n<head>n<title>PAGE 1</title>n</head>n<body>n<h1>Thank you for your feedback. We will get back to you shortly.</h1>n”;
‘</body></html>’;
//This is the end of the PHP code
?>