简体   繁体   中英

post form data through two php pages

I have a Submit form and I originally used $_post to get the from data which worked perfectly. But i then wanted to the user to see what they had inputed and verify that the information was correct before submitting.

So the user See's this screen clicks submit and it will the do the original functionality of submitting the data to an SQL Database. There for how do i get the form data from the original HTML form and get it too go through one php form in the form of $_post and get the same data to go through the next page.

Is there a PHP version of javascripts get.elementId ? How can I parse the variables of the original form through two php scripts.

use session or cookie to store the posted data, after confirmation via this page store the data into db

in your confirmation php page

$_SESSION['post_array'] = $_POST;

and after confirmation

$post_array = $_SESSION['post_array'];
$name = $post_array['first_name'];
.... etc.,

I agree with @N0nh4x0r, just wanted to give an alternative using hidden form fields. You can pass the data to hidden forms, and then when the user clicks submit on the confirmation page, the data is resent to the server.

<input type=hidden name=username value='{$_POST['username']}'>
<input type=hidden name=email value='{$_POST['email']}'>

Thank you for registering, $_POST['username']
...blah blah blah...

Please remember that serverside validation should be done after the second submission, never trust the data to stay the same even if it is hidden.

I am not sure if I have understood your question.

I think you should verify everything first in JavaScript and then use AJAX to post the data to the PHP script without reloading the whole page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM