Hello, I’ve started to learn PHP and I have a .htm page where is simple form, you have to introduce your name, email etc but at the end you have to input username, password and password confirmation. And when you press submit, it should open my .php file where the name, email and all the fields are displayed except the password. Basically it shows all the data the were entered in the form.
But if the passwords don’t match, the form should be redisplayed with an error message that says “Passwords don’t match” and all the fields should be repopulated with the previous data, just the passwords field should be blank.
I wrote this code in my .php file and it redisplays the form, but all the fields are blank.
<?php
$password1 = $_POST["password"];
$password2 = $_POST["confirmpassword"];
if ($password1 != $password2)
{
header("Location: ".$_SERVER['HTTP_REFERER']);
exit;
}
?>
Does anyone know how to display the error message and to repopulate the fields that were completed?
Thank you.