简体   繁体   中英

how can i pass the data of the first form to the second one without recording those data on the database yet?

I have 2 forms on my project and their data must be recorded on the same row with the same database, so when you click the next button on the first form, the user will be directed to the second one, but I want not to record first its values on the database, because records/data of the first and the second form must be of the same row and I want them to be inserted on my database when you hit the save button on the second form, the issue here is that, how can i pass the data of the first form to the second one without recording those data on the database yet? Can anyone help me?Thanks a lot. :)

form1.php

<?php
session_start();
if(isset($_SESSION['name'])):
    header("Location: http://mysite.ext/form2.php");
else:
?>
<form action="form2.php" method="POST" name="form1">
    <input type="name" name="name"/><br/>
    <input type="submit" value="Submit"/>
</form>
<?php endif; ?>

form2.php

<?php
session_start();
if(!isset($_SESSION['name'])):
    header("Location: http://mysite.ext/form1.php");
elseif(isset($_POST['password'], $_SESSION['name'])):
    echo 'Thank you', $_SESSION['name'] ,'. We will verify your password, ', $_POST['password'],' now.';    
else:
?>
<form action="form2.php" method="POST" name="form2">
    <input type="password" name="password"/><br/>
    <input type="submit" value="Submit"/>
</form>
<?php endif; ?>

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