...

View Full Version : Contact Us form redirect to home page after submit



freelancekaleem
04-24-2012, 08:12 AM
I have developed a contact us page and also PHP code that works perfect. Know the only problem is that after submitting the form it shows only "Message sent" on a new page. I want that after submitting the form page will redirect back to home page. It is only one page "Landing Page". Here is the PHP code.

<?php

if(!$_POST) exit;

$email = $_POST['email'];


//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message','phone');
$required = array('name','email','message','phone');

$your_email = "todd@toddandersonhomes.com";
$email_subject = "Free Credit Report: ".$_POST['subject'];
$email_content = "Following is the free credit report detail from client:\n";

foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}

if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
?>

HTML Code:


<form action="contact.php" method="post">

<div class="formele">
<ul>
<li>
<label>Name:</label>
<input type="text" id="name" name="name" class="text2" />
</li>
<li>
<label>Telephone:</label>
<input id="name" type="text" name="phone" class="text2" />
</li>
<li>
<label>E-mail:</label>
<input id="name" type="text" name="email" class="text2" />
</li>
<li>
<label>Address:</label>
<input id="name" type="text" name="message" class="text2" />
</li>

<li class="button">
<input type="image" type="text" src="images/submit.png" />
</li>
</ul>
</div><!--Contact Form Ends Here -->
</form>
Here is the link of the page: http://www.designsblessing.com/Landingpages/

abduraooft
04-24-2012, 08:38 AM
if(@mail($your_email,$email_subject,$email_content)) {
//echo 'Message sent!';
header("Location:http://www.designsblessing.com");
exit();
}

abduraooft
04-24-2012, 08:38 AM
if(@mail($your_email,$email_subject,$email_content)) {
//echo 'Message sent!';
header("Location:http://www.designsblessing.com");
exit();
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum