|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
passing $_POST among pages
I'm designing a database app (PHP and MySQL) and am using HTML forms to collect the data. I want to present a data confirmation page (field names and data, but without the form field entry boxes) to the user before adding the data to the database.
The user will either confirm the data, at which point it is added to the database, or will choose to edit the data and is taken back to the original form page, which displays the previously entered data. No problem posting the data directly from the form to the database, nor dispalying the form data on the confirmation page, via echoing the values from the $_POST array, but I'm stumped trying to figure how to pass the existing $_POST array either back to the original form (where the 'value=' attributes of the input tags will display what was entered), or on to the database, now that I've got the confirmation page in the middle of the process. The confirmation page design is a second form with POST and EDIT submit buttons, which is the source of the problem with this design, since no fields exist to get loaded into $_POST on submission. Is there a way to make the key value pairs in $_POST persist, or to load them into the new $_POST that the second from generates? Or is there a better approach altogether? Thanks, Muiz |
|
#2
|
|||
|
|||
|
update: passing $_POST
Since posting my question, I realized that my data confirmation page form needed hidden fields containing the values in $_POST passed to it by the original data entry form, so that there would be data to post when the confirmation page is submitted.
Posting to the database from the secondary page now works, but reloading the original page, with previously entered data, so the user can correct mistakes still doesn't work. I'm using a variable ($submitFormAction) as my form action= attribute, set to $PHP_SELF, so that an IF statement at the top of the confirmation page is triggered to decide whether to insert the record into the database, or reload the original data entry page for corrections ... ----------------PHP Code-------------------------------------------------- if ($_POST['submit'] == 'EditData') { // don't post, go back to Add page to edit data $validGoTo = 'addSubscriber.php'; header(sprintf("Location: %s", $validGoTo)); exit(); // tried commenting this line, but doesn't change it } elseif ($_POST['submit'] == 'AddSubscriber') { // load MySQL vars and insert into database .... this segment works } -------------------------------------------------------------------------------- The first segment of the IF statement above correctly loads the 'addSubscriber.php' page, but without the $_POST array, so that all of the value='$_POST['fieldname']' field attributes for the addSubscriber form are empty. PHPinfo() indicates that the GET method is being used, rather than POST, even though POST is the method in the form on the confirmation page. Any ideas how I can guarantee a POST server method, or force it? Thanks, Muiz |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > passing $_POST among pages |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|