Jump to content

Adding A Confirmation Page To My Contact Us Php Page


podarum
 Share

Recommended Posts

Hi,I had this code form the net .. it's a php Contact Us form. Everything works fine and it does exactly what I need, except if someone can help me with this minor thing.. right now it uses a generic 'Email Received Confirmation page' but I'd like to change it to my confirmation.html page and then after 4 seconds redirected back to the Contact Us page.. Anyone can help with this? thanks.. Here's the code I'm using.

<?php/* Email Variables */$emailSubject = 'contactformprocess!';$webMaster = 'info@risksolutions.ca';/* Data Variables */$email = $_POST['email'];$name = $_POST['name'];$comments = $_POST['comments'];$body = <<<EOD<br><hr><br>Name: $name <br>Email: $email <br>Comments: $comments <br>EOD;$headers = "From: $email\r\n";$headers .= "Content-type: text/html\r\n";$success = mail($webMaster, $emailSubject, $body,$headers);/* Results rendered as HTML */$theResults = <<<EOD<html><head><title>sent message</title><meta http-equiv="refresh" content="4;URL=http://www.risksolutions.ca/ContactUS.php"><style type="text/css"><!--body {background-color: #FFF;font-family: Arial, Helvetica, sans-serif;font-size: 20px;font-style: normal;line-height: normal;font-weight: normal;color: #fec001;text-decoration: none;padding-top: 200px;margin-left: 150px;width: 800px;}--></style></head><div align="center">"We have received your email and we will respond as soon as possible.!You will return to the Contact Us page in a few seconds. Thank you. !"</div></div></body></html>EOD;echo "$theResults";?>

Link to comment
Share on other sites

<?php/* Email Variables */$emailSubject = 'contactformprocess!';$webMaster = 'info@risksolutions.ca';/* Data Variables */$email = $_POST['email'];$name = $_POST['name'];$comments = $_POST['comments'];$body = <<<EOD<br><hr><br>Name: $name <br>Email: $email <br>Comments: $comments <br>EOD;$headers = "From: $email\r\n";$headers .= "Content-type: text/html\r\n";$success = mail($webMaster, $emailSubject, $body,$headers);/* Results rendered as HTML */

header("Location: http://www.site.com/confirmation.html");?>

You can use header("Location: confirmation.html"); after the /* results */ commentand then use javascript on confirmation to redirect to another page.hope it helps!
Link to comment
Share on other sites

Let's see... header should work:

<?phpheader("Location: http://www.google.com");exit;?>

But if you get any header errors with messages it probably means that text shouldn't be 'echoed' before a header.

Link to comment
Share on other sites

Now I'm getting an error because I attempted to add another field $subject and I don't know where it's going wrong. I want this subject to be another field and go into the subject field in the email..

<?php/* Email Variables */$webMaster = 'info@risksolutions.ca';$subject = "$_POST["subject"]";/* Data Variables */$email = $_POST['email'];$name = $_POST['name'];$subject = $_POST['subject'];$comments = $_POST['comments'];$body = <<<EOD<br><hr><br>Name: $name <br>Email: $email <br>Subject: $subject <br>Comments: $comments <br>EOD;$headers = "From: $email\r\n";$headers .= "Content-type: text/html\r\n";$success = mail($webMaster, $subject,  $body,$headers);/* Results rendered as HTML */header("Location: http://www.risksolutions.ca/EmailThankYou.php");?>

Link to comment
Share on other sites

Now I'm getting an error because I attempted to add another field $subject and I don't know where it's going wrong. I want this subject to be another field and go into the subject field in the email..
<?php/* Email Variables */$webMaster = 'info@risksolutions.ca';$subject = "$_POST["subject"]";/* Data Variables */$email = $_POST['email'];$name = $_POST['name'];$subject = $_POST['subject'];$comments = $_POST['comments'];$body = <<<EOD<br><hr><br>Name: $name <br>Email: $email <br>Subject: $subject <br>Comments: $comments <br>EOD;$headers = "From: $email\r\n";$headers .= "Content-type: text/html\r\n";$success = mail($webMaster, $subject,  $body,$headers);/* Results rendered as HTML */header("Location: http://www.risksolutions.ca/EmailThankYou.php");?>

Link to comment
Share on other sites

Your subject line is wrong:

$subject = "$_POST["subject"]";

You're using quotes for a variable. Don't:

$subject = $_POST['subject'];OR$subject = $_POST["subject"];

I prefer single quotes, but doubles work too.Adding header('location: confirmation.html'); (again single or double quotes work) should redirect to the confirmation, and something like:

<script type="text/javascript">function Redirect(){	window.location.href = (your contact page);}setTimeout("Redirect()", 4000);</script>

should redirect back, if you put that on the confirmation page.Edit: Small mistakes.

Edited by ragae
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...