johnsmith153 Posted July 21, 2010 Share Posted July 21, 2010 I submit forms to the same page so I can use value="$_POST['formField']" in the form to display values entred to user if form submit is not fully completed. However, I then get the web page expired problem. If I submit to a different script I then lose $_POST values when I header redirect back to display the form. I suppose the question is "how do I do form submitting where I don't get the web-page expired problem AND I can reuse $_POST values?" Quote Link to comment https://forums.phpfreaks.com/topic/208410-how-is-the-best-way-to-submit-a-form/ Share on other sites More sharing options...
gwolgamott Posted July 21, 2010 Share Posted July 21, 2010 What's your code look like? Quote Link to comment https://forums.phpfreaks.com/topic/208410-how-is-the-best-way-to-submit-a-form/#findComment-1089053 Share on other sites More sharing options...
johnsmith153 Posted July 21, 2010 Author Share Posted July 21, 2010 I don't think it matters. It is a normal form. I just need to know the bst way to do ANY form so that I: (a) don't get web page expired AND (b) can reuse $_POST['field'] values Quote Link to comment https://forums.phpfreaks.com/topic/208410-how-is-the-best-way-to-submit-a-form/#findComment-1089067 Share on other sites More sharing options...
KevinM1 Posted July 21, 2010 Share Posted July 21, 2010 You shouldn't be getting a web page expired error. Sticky forms (the kinds of forms that post back to themselves and retain user submitted info) are ubiquitous. Show your code. Quote Link to comment https://forums.phpfreaks.com/topic/208410-how-is-the-best-way-to-submit-a-form/#findComment-1089073 Share on other sites More sharing options...
johnsmith153 Posted July 21, 2010 Author Share Posted July 21, 2010 Answer: capture on the processing (non form) page: <?php session_start(); $_SESSION['postData'] = $_POST; ?> Display on the form page <?php session_start(); $postData = $_SESSION['postData']; ?> <form> <input type="text" name="name" value="<?php echo $postData['name']; ?>" /> </form> <?php unset($_SESSION['postData']);//important so when return to page, form shows blank ?> Quote Link to comment https://forums.phpfreaks.com/topic/208410-how-is-the-best-way-to-submit-a-form/#findComment-1089076 Share on other sites More sharing options...
gwolgamott Posted July 21, 2010 Share Posted July 21, 2010 I submit forms to the same page so I can use value="$_POST['formField']" in the form to display values entred to user if form submit is not fully completed. However, I then get the web page expired problem. Was curious what method you were using... as that just means that it just doesn't work. Not why it doesn't work, just that you are using $_POST. This could be for a hundred reasons is all. Would have mattered to get more help was all, was just trying to prod some help for you thought you had a specific issue. Didn't realize you wanted a broad answer. Anyways... to answer your questions: (a) This shouldn't happen if php is running correctly, this just means the php code did not compile to run correctly and you have error reporting off most likely. (b) You need checks in place to check if this page is first run and checks for if it is not first run then error checking for blank form fields. Then depending on how you are using the $_POST variables you could dump it at the beginning of the script to a dummy variable if it is causing issues with multiple use, not sure how it will be used but it's a method that could use as well. Quote Link to comment https://forums.phpfreaks.com/topic/208410-how-is-the-best-way-to-submit-a-form/#findComment-1089078 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.