jameson9 Posted February 28, 2007 Share Posted February 28, 2007 Hello, I have a php script that works fairly well so far, taking data from a form and inserting into the mysql db. At present I have it set up so that it echoes a thank you message once submitted: if(isset($_POST['Submit'])) { echo "Thank you for registering!\n"; } However, instead of a blank page with just the echo message, I would like the user to be directed to another page on the site. I have tried various combinations of <ahref= ...all to no avail. Every php tutorial site covers how to submit a form etc but none seem to tell you what to do after that. I don't want the user left in dead air. How do I get the php script to automatically forward them to a link within the site once the form has been submitted? Link to comment https://forums.phpfreaks.com/topic/40600-linking-to-next-html-page-using-php/ Share on other sites More sharing options...
jwk811 Posted February 28, 2007 Share Posted February 28, 2007 as long as no html is outputted to the broswer before this you can do header("Location: thankyou.html"); and that will redirect them. is that what you need? Link to comment https://forums.phpfreaks.com/topic/40600-linking-to-next-html-page-using-php/#findComment-196422 Share on other sites More sharing options...
boo_lolly Posted February 28, 2007 Share Posted February 28, 2007 you're probably going to have output printed to the browser, so use a meta refresh tag like this: <?php if(isset($_POST)){ echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=your_page.html\">"; } ?> Link to comment https://forums.phpfreaks.com/topic/40600-linking-to-next-html-page-using-php/#findComment-196431 Share on other sites More sharing options...
jameson9 Posted March 1, 2007 Author Share Posted March 1, 2007 Thanks guys, I appreciate it! Boo_lolly, yours works perfectly. Just wondering about the CONTENT=\"0; what does the 0 refer to? You see, I have divided up the registration page into 2 pages. I would like the user id created by mysql for the preceding page to be put into a field on the 2nd page. The user id is autoincremented by mysql. Is there a simple (I am such a newbie, be gentle ) way of making the user id from page 1 into a variable which can be inserted into page 2's table when page 2 is posted? Link to comment https://forums.phpfreaks.com/topic/40600-linking-to-next-html-page-using-php/#findComment-196511 Share on other sites More sharing options...
boo_lolly Posted March 1, 2007 Share Posted March 1, 2007 Thanks guys, I appreciate it! Boo_lolly, yours works perfectly. Just wondering about the CONTENT=\"0; what does the 0 refer to? You see, I have divided up the registration page into 2 pages. I would like the user id created by mysql for the preceding page to be put into a field on the 2nd page. The user id is autoincremented by mysql. Is there a simple (I am such a newbie, be gentle ) way of making the user id from page 1 into a variable which can be inserted into page 2's table when page 2 is posted? the '0' refers to the amount of seconds to delay the refresh. so, if you put 5, it would take 5 seconds to forward the user to the targetpage. Link to comment https://forums.phpfreaks.com/topic/40600-linking-to-next-html-page-using-php/#findComment-196679 Share on other sites More sharing options...
boo_lolly Posted March 1, 2007 Share Posted March 1, 2007 sorry i missed the second question in your post. i would advise using sessions to store these values. you may feel it's too early, or difficult, but i promise you they're not that hard, and they are very important to know. check out the manual for sessions. scroll down until you see 'Table Of Contents', and start from there. explore each session function, and you'll be on your way! Link to comment https://forums.phpfreaks.com/topic/40600-linking-to-next-html-page-using-php/#findComment-196965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.