Page 1 of 1
Resending $_POST Without a Form?
Posted: Sun Aug 17, 2008 6:23 pm
by Zzarkc-20
I'm not sure this is the right forum to post this question, but I'm curious to know if there's a way to resend $_POST to another page. Say you have a form that sends the data via $_POST to itself. There you can check the form, and then display the information if it is all correct, and let them check it one last time. Is there then an easy way to send the $_POST with all the information in it to another page to process it (like send an email to the user, server processing, etc.) I can think of a lengthy way involving recreating another form, hiding all the elements, and adding the values from the previous form into new variables. That seems a bit tasking to me, so I'm curious if there is a more concise method. Thanks!
Re: Resending $_POST Without a Form?
Posted: Sun Aug 17, 2008 6:35 pm
by allspiritseve
Could you maybe have a hidden field that lets the script know whether to display the form for verification, or process it? Then you could check for it like this:
Code: Select all
if ($_POST['hidden_field'] = 'verify'):
// Display for verification
elseif ($_POST['hidden_field'] = 'process'):
// Process
else:
// Display form
endif;
Re: Resending $_POST Without a Form?
Posted: Sun Aug 17, 2008 7:17 pm
by Zzarkc-20
I suppose that would get the job done as well. It doesn't really get the $_POST off the page and too another one without a form though.
I suppose this could be a good reason to use $_GET instead. You could just append the URL with the variables that way and send it to the new page (that they could bookmark). If I went that route I would need a good way to change the variables from $_POST to $_GET.
Also, with the form displaying it's content (information is already entered), is it safe to use a simple back button (using Javascript and histories) to navigate the person back to the page to change information?
Re: Resending $_POST Without a Form?
Posted: Sun Aug 17, 2008 7:21 pm
by allspiritseve
If you are set on processing in a different script, then maybe you could make the intermediate page (verify form input) a new script. That way, form (1) posts to verify (2), which posts to process (3).
Re: Resending $_POST Without a Form?
Posted: Sun Aug 17, 2008 7:27 pm
by Zzarkc-20
Right. That's kind of the idea I want to get too, but I can't figure out the way to get the $_POST to be sent again from the verify stage to the processing stage. I'm probably being ignorant, but from the book I'm learning from, it says nothing about resending $_POST without a form.
Re: Resending $_POST Without a Form?
Posted: Sun Aug 17, 2008 7:31 pm
by allspiritseve
I know you're not displaying the form again, but you are essentially submitting form information if you display information for verification and ask the user to click "submit". The solution to this is to place the form data in hidden fields, and have the form post to the process page. The only visible part of the form will be the submit button.