Jump to content

linking to next html page using php


jameson9

Recommended Posts

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

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\">";
        }
?>

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?

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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.