vj5 Posted April 5, 2008 Share Posted April 5, 2008 I have two web pages called update.php and show.php. If i want to go from update.php, update the field in the database, want to sent the user back to update.php. Like wise, do the same for show.php. Both files have one update file called notes.php in which the update is taking place. How will I sent users back to two different pages from one back button(which is in notes.php)? Link to comment Share on other sites More sharing options...
jeffman Posted April 5, 2008 Share Posted April 5, 2008 If i want to go from update.php, update the field in the database, want to sent the user back to update.php.The normal thing would be to have the form printed by update.php point to update.php itself. A data parsing function at the top of update.php would check for some post value, and if it exists, do the updating right there. Then control would fall through to whatever update.php is already written to do.Spreading the functions out over many files is fine. You don't always need them, so why load them? And some routines can be used by many documents. That's what include statements are for.So I guess, if this is how you want things, you could include notes.php, or some version of it, and call its updating functions from update.php AND show.php.I confess I wasn't 100% clear what your post meant, so I apologize if my answer isn't relevant. Link to comment Share on other sites More sharing options...
vj5 Posted April 5, 2008 Author Share Posted April 5, 2008 I want add the back button in notes.php and want to do in php. Can someone please help? Link to comment Share on other sites More sharing options...
Zie Posted April 5, 2008 Share Posted April 5, 2008 Why don't you do it in javascript? Seems more practical. Link to comment Share on other sites More sharing options...
vj5 Posted April 5, 2008 Author Share Posted April 5, 2008 Why don't you do it in javascript? Seems more practical.I tried in javascript and it works but my requirement is in php. Link to comment Share on other sites More sharing options...
Synook Posted April 6, 2008 Share Posted April 6, 2008 You can use the $_SERVER['HTTP_REFERER'] to get the previous page, then send a location header. E.g. header("location:{$_SERVER['HTTP_REFERER']}"); Link to comment Share on other sites More sharing options...
vj5 Posted April 6, 2008 Author Share Posted April 6, 2008 You can use the $_SERVER['HTTP_REFERER'] to get the previous page, then send a location header. E.g.header("location:{$_SERVER['HTTP_REFERER']}"); Is there a way to do with $HTTP_GET_VARS and get the captured variable and pass into a url to go back to the same page from where it started? Link to comment Share on other sites More sharing options...
Synook Posted April 6, 2008 Share Posted April 6, 2008 Well you could have a hidden field in your form that specifies what that page's URL is. E.gin updates.php have <input type="hidden" name="url" value="updates.php" /> in show.php have <input type="hidden" name="url" value="show.php" /> and in notes.php (assuming your forms' methods are GET) header("location:{$_GET['url']}"); By the way, $HTTP_GET_VARS is old with PHP 3, you should use $_GET. Link to comment Share on other sites More sharing options...
vj5 Posted April 6, 2008 Author Share Posted April 6, 2008 Well you could have a hidden field in your form that specifies what that page's URL is. E.gin updates.php have<input type="hidden" name="url" value="updates.php" /> in show.php have <input type="hidden" name="url" value="show.php" /> and in notes.php (assuming your forms' methods are GET) header("location:{$_GET['url']}"); By the way, $HTTP_GET_VARS is old with PHP 3, you should use $_GET. Thank you, I was looking something like the one you have specified but how will I link this the back button? Link to comment Share on other sites More sharing options...
Synook Posted April 6, 2008 Share Posted April 6, 2008 Oh - well then instead of a header you would output the URL into a link (in notes.php) <a href="<?php echo $_GET['url']; ?>">Go back</a> Link to comment Share on other sites More sharing options...
vj5 Posted April 6, 2008 Author Share Posted April 6, 2008 Oh - well then instead of a header you would output the URL into a link (in notes.php)<a href="<?php echo $_GET['url']; ?>">Go back</a> Thank you. This is what I was looking for. I have one doubt:Can I have the value for the input like this:<input type="hidden" name="url" value="update.php?claimid=$cid&loc=update"> Link to comment Share on other sites More sharing options...
kv79 Posted April 6, 2008 Share Posted April 6, 2008 Why do not try by yourself to write a code ? Link to comment Share on other sites More sharing options...
Synook Posted April 7, 2008 Share Posted April 7, 2008 Mean, kv79 Can I have the value for the input like this:Yes, but you just need to get PHP to parse the $cid variable. Also, that way don't forget to append .php onto loc<input type="hidden" name="url" value="update.php?claimid=<?php echo $cid; ?>&loc=update"> Link to comment Share on other sites More sharing options...
vj5 Posted April 7, 2008 Author Share Posted April 7, 2008 Mean, kv79 :)Yes, but you just need to get PHP to parse the $cid variable. Also, that way don't forget to append .php onto loc<input type="hidden" name="url" value="update.php?claimid=<?php echo $cid; ?>&loc=update"> Thank you for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.