nickelus Posted July 15, 2009 Share Posted July 15, 2009 is there a way to redirect a user back from a processing page to the previous page (that requires POST variables again) without using sessions or is there a better way to accomplish this. I've been thinking about re-posting the data on the processing page and header() to redirect but it doesn't sound efficient. Quote Link to comment https://forums.phpfreaks.com/topic/166075-header-location-requires-post-variables-again/ Share on other sites More sharing options...
ignace Posted July 15, 2009 Share Posted July 15, 2009 If you use header() you lose anything that was posted or that was part of the query part of the url. The only way is to include the previous page in the processing page or vice versa. You are probably referring to a form and a processing page and you want to send them back if an error occured but the fields have to be left filled in. Just include the processing page on the form page. This way you keep the php minimal amongst the html. It's a struggle we all fought and the best approach are view helpers. These little bastards are allowed to spit out html (as they are designed for this specific purpose) and allows us to work with models in a clean php fashion (with no html mess). These models then use these view helpers to properly render their contents in the view. Quote Link to comment https://forums.phpfreaks.com/topic/166075-header-location-requires-post-variables-again/#findComment-875841 Share on other sites More sharing options...
JonnoTheDev Posted July 15, 2009 Share Posted July 15, 2009 If you use header() you lose anything that was posted or that was part of the query part of the url. Not at all. Change the script requiring the POST data to use: // from $_POST['varname'] to $_REQUEST['varname']; Then you can use paramaters within the url i.e. header("Location:page.php?varname=".$_REQUEST['varname']); However if you are posting text strings then I do not recommend. Either apply a better design to your code or stor the data within a session after it has been posted. Quote Link to comment https://forums.phpfreaks.com/topic/166075-header-location-requires-post-variables-again/#findComment-875852 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.