bella_3333 Posted August 12, 2009 Report Share Posted August 12, 2009 Hi I have this php code so when you click submit it goes to a thank you page, but what i actually want is it to say thank you and go back to the index page automatically. Does anyone know how to do this. Here's the code <?php echo " Thank you, $_POST[name], Your message has been sent."; //start building the mail string $msg = "Name; $_POST[name]\n"; $msg .= "E-Mail: $_POST\n"; $msg .= "Message: $_POST\n"; $recipient = "kreativ108@gmail.com"; $subject = "comment form"; $mailheaders = "From: My Website \n"; $mailheaders .= "Reply-to: $_POST"; //send the mail mail($recipient, $subject, $msg, $mailheaders); ?> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted August 12, 2009 Report Share Posted August 12, 2009 You'll need to use the header() function: http://us2.php.net/manual/en/function.header.php Quote Link to comment Share on other sites More sharing options...
bishwadeep Posted August 18, 2009 Report Share Posted August 18, 2009 Quote Link to comment Share on other sites More sharing options...
bella_3333 Posted August 19, 2009 Author Report Share Posted August 19, 2009 Thanks bishwadeep that helps. Thanks falkencreative as well. Got it working, with proper code now. Quote Link to comment Share on other sites More sharing options...
cugopob.vlad Posted August 20, 2009 Report Share Posted August 20, 2009 The above resolution works with javascript but if you wanted to do it in php you could use $page = 'index.php'; $sec = "5" header("Refresh: $sec; url=$page"); the above code would redirect you in 5 seconds. Quote Link to comment Share on other sites More sharing options...
dms Posted August 21, 2009 Report Share Posted August 21, 2009 (edited) in php you could use $page = 'index.php'; $sec = "5" header("Refresh: $sec; url=$page"); the above code would redirect you in 5 seconds. Will this header function cause the new page to be refreshed every 5 seconds? If not, I like it. Edited August 23, 2009 by dms Quote Link to comment Share on other sites More sharing options...
falkencreative Posted August 21, 2009 Report Share Posted August 21, 2009 Only if the $page variable is set to the same name as the page this code is in. That would cause a loop, reloading the same page over and over. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.