titanium Posted February 19, 2016 Share Posted February 19, 2016 (I already posted this in ProcessWire's issue list at github a week ago, but I'm not too sure if this really is an issue I should Ryan bother with. I hope it can be better answered/discussed by the community). I would like to collect form data in a session and do a redirect afterwards. After the redirect happens, I would like to read the form data back from the session. This follows the concept of the PRG-Pattern, which I consider as a good practice to avoid duplicate form submissions. In 2.7.2, the following code worked flawlessly. In 3.0.8, I can't get it to work anymore. Here's my simple test case (save it as "test.php", in parallel to the index.php). I hope somebody can give me a hint what's wrong with it. <?php include './index.php'; if ($input->post->submit) { $session->input = $input; $session->redirect('./test.php'); } if ($session->input && $session->input->post) { // 2.7.2: echoes "1" // 3.0.7: echoes nothing! foreach ($session->input->post as $value) { echo $value; } $session->remove('input'); } ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="" method="post"> <button type="submit" name="submit" value="1">send</button> </form> </body> </html> Link to comment Share on other sites More sharing options...
flydev Posted February 19, 2016 Share Posted February 19, 2016 Just tested your code under PW 2.7 and 3, I can't get it working on both version with the line $session->redirect(basename(__FILE__)); Commenting the line, it show the integer (value 1) on both version. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 19, 2016 Share Posted February 19, 2016 For the redirect maybe read these comments: https://github.com/ryancramerdesign/ProcessWire/issues/1605 1 Link to comment Share on other sites More sharing options...
titanium Posted February 20, 2016 Author Share Posted February 20, 2016 Just tested your code under PW 2.7 and 3, I can't get it working on both version with the line $session->redirect(basename(__FILE__)); Commenting the line, it show the integer (value 1) on both version. Thanks for testing! If you comment the line, than value 1 is shown. The difference is only visible after the redirect. May I ask you to try again with: $session->redirect('./test.php'); given the file is named "test.php". I did edit my version above. Link to comment Share on other sites More sharing options...
flydev Posted February 20, 2016 Share Posted February 20, 2016 Same result, I already tested it when LostKobrakai answered. On both version I dont get any value if a redirect is triggered. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now