blogfisher Posted March 22, 2009 Share Posted March 22, 2009 Hello, I want to know the webpage to return back after submitting forms in php. MY application contains basically one php file e.g. info.php which shows users info 10 users data on one page. When user click on NEXT button it shows another 10 as info.php?next=1, info.php?next=2 ... Page has a form code where i am taking basic inputs such as name, address, email etc. When user submit these data, i call a adddata.php file which add data to my database. Now i want to know which webpage i have to go back. if form is submitted from info.php?next=1 or infor.php?next=5 ...then i should return to same page. Is there any php function available to know the previous webpage from where form is submitted ? Well, simple way is to pass page number 1,2... along with form data, however i would like to know is this possible without passing this info ? Link to comment https://forums.phpfreaks.com/topic/150544-how-to-know-previous-webpage-after-submitting-form/ Share on other sites More sharing options...
Allan- Posted March 22, 2009 Share Posted March 22, 2009 echo '<input type="hidden" name="next" value="'.$_GET['next'].'" />'.PHP_EOL; or $_SESSION Link to comment https://forums.phpfreaks.com/topic/150544-how-to-know-previous-webpage-after-submitting-form/#findComment-790741 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 submit the page to itself and put the php code at the top whenever the user clicks the next button the page will load again or if you want to keep those files seperate then put this at the top of your form page <?php include('adddata.php'); // or whatever the file that gets the 10 records ?> Link to comment https://forums.phpfreaks.com/topic/150544-how-to-know-previous-webpage-after-submitting-form/#findComment-790756 Share on other sites More sharing options...
Yesideez Posted March 22, 2009 Share Posted March 22, 2009 If you do this: var_dump($_SERVER); Then view the page source you can view loads of useful information that can be used including what the page was that you just came from. As Allan as posted, using a hidden input in your form can be used and you don't have to populate it with a $_GET, you can put whatever you want in there like a code for each page you want to reference. This can then be checked in the script handling the input. Or as FaT3oYCG has said (which is what I do mixed with a check of $_SERVER) Link to comment https://forums.phpfreaks.com/topic/150544-how-to-know-previous-webpage-after-submitting-form/#findComment-790765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.