Here’s the situation: registration.php with inputs (like firstname, lastname, password) and registrationErrors.php – having self-written error-checks and returning the type of error to the initial registration.php, where it is shown to the user.
In case one of my self-written error occurs, I’d like to save the inputs (registration.php) the user has already done and only clear the input with the error in it.
I have seen a couple of posts having the same problem – but mine’s slightly different. Since the data is sent to
<form action="registrationErrors.php" method="post" ...>
, the suggestion
value="<?php echo isset($_POST["firstname"]) ? $_POST["firstname"] : ''; ?>"
doesn’t work, since it would have to be sent to:
<form action="registration.php"...>
Any idea how to keep my structure of the two php-files and still have the already-input data saved?
2
Answers
You can save data on session in a file registrationErrors.php and then retrieve it on registration.php.
Also You can send data using GET parameter to registration.php.
this will work.
OR even
this will work
Please use session variables to do what you want
PHP (submission form)
registrationErrors.php
session_start();
at the start of all related php scripts