please help me with one question: register script
I have a good working register script.
When people leave one field blank they get the message that they have to fill in all the fields. I do this with the following code:
Code:
//Sanitize the POST values
$name = clean($_POST['name']);
$email = clean($_POST['email']);
$confemail = clean($_POST['confemail']);
//Input Validations
if($name == '') {
$errmsg_arr[] = 'Name missing';
$errflag = true;
}
if($email == '') {
$errmsg_arr[] = 'Email missing';
$errflag = true;
}
if($confemail == '') {
$errmsg_arr[] = 'Confirmation email missing';
$errflag = true;
}
if($pw == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($confpw == '') {
$errmsg_arr[] = 'Confirmation password missing';
$errflag = true;
}
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: register-form.php");
exit();
}
The problem is that all the information that already was entered.. disappears.
I want to solve this with the following php, but I donīt know where to place it in the script.
PHP Code:
?>
<form action="this.php" method="post">
Name: <input type="text" name="name" <?php if(isset($name)){ echo "value=\"$name\"";}?> />
Address: <input type="text" name="address" <?php if(isset($address)){ echo "value=\"$address\"";}?> />
</form>
<?php