I want to display the information a user has submited on my registration forms, so I'm using
echo $_POST["name_of_field"], but for some reason the information isn't being displayed.
I have registerNewStudent2.php, registerNewStudent3.php, registerNewStudent4.php.
I want to display the registerNewStudent2.php forms in registerNewStudent4.php.
But from what I've read values in $_POST stay only for the next request.. So how can i do it? Here's my code:
registerNewStudent2.php
<form name="myForm" action="registerNewStudent3.php" onsubmit="return validate()" method="POST">
<tr>
<td>Nome</td>
<td><input type="text" style="width:270px; color:gray" STYLE="color:gray" name="name"></td>
</tr>
<tr>
<td>BI</td>
<td><input type="text" style="width:270px; color:gray" name="BI";></td>
</tr>
<tr>
<td>Curso</td>
<td><input type="text" style="width:270px; color:gray" name="course"></td>
</tr>
<input type="submit" value="Next">
</form>
registerNewStudent4.php
<?php
echo $_POST["name"];
echo $_POST["BI"];
echo $_POST["course"];
?>
The easiest way I've found would be to add a hidden field into the HTML with the PHP, like so:
<input type="hidden" name="name" value="<?php echo $_POST["name"]; ?>">
That way, when the form is submitted, a hidden variable will also be posted.
EDIT:
Alternatively, you can store them as $_SESSION
variables, that will be accessible until the user navigates away from your website. Example: $_SESSION["name"]=$_POST["name"];
Save your data in session in the registerNewStudent2.php like this:
$_SESSION['name'] = $_POST['name'];
Then you can access those data in registerNewStudent4.php like this
echo $_SESSION['name'];
EDIT: In every page that you want to use session you must write first session_start()
on the top of your 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.