podarum Posted October 20, 2009 Share Posted October 20, 2009 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 More sharing options...
Kameloh Posted October 20, 2009 Share Posted October 20, 2009 <?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 More sharing options...
podarum Posted October 20, 2009 Author Share Posted October 20, 2009 Thanks Kameloh,I'll give it a try and post... but in test (since I don't currently have access to the internet), it didn't run smoothly...like it didn't work..I think it's becasue of no connectivity.. Link to comment Share on other sites More sharing options...
Kameloh Posted October 20, 2009 Share Posted October 20, 2009 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 More sharing options...
podarum Posted October 21, 2009 Author Share Posted October 21, 2009 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 More sharing options...
podarum Posted October 21, 2009 Author Share Posted October 21, 2009 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 More sharing options...
podarum Posted October 21, 2009 Author Share Posted October 21, 2009 Please disregard my last posts..trigger happy... but I figured it out.. the computer was having a mind of it's own..how dare she.. Link to comment Share on other sites More sharing options...
shadowayex Posted October 21, 2009 Share Posted October 21, 2009 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. Link to comment Share on other sites More sharing options...
Kameloh Posted October 21, 2009 Share Posted October 21, 2009 Also there's no need for you two declare subject twice Link to comment Share on other sites More sharing options...
shadowayex Posted October 21, 2009 Share Posted October 21, 2009 Also there's no need for you two declare subject twice Good call. Didn't see that. Yeah, you already have a subject variable . Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.