Hello, I want to make this registration script tell the user when the passwords they have entered are not matching.
When this script is run after a form in an html document it should redirect to index.php and show the error i.e. not matching.
<?php
session_start();
require "connect.php";
$email = $_POST['email'];
$alias = $_POST['alias'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
if($password == $password2)
{
$passwordHash = sha1($_POST['password']);
}
else
{
header("Location: index.php");
$error = "Password does not match.";
$_SESSION["error"] = $error;
}
$sql = "INSERT INTO accounts VALUES('".$email."','".$alias."','".$passwordHash."')";
$result = mysql_query($sql)
or die("MySQL Error: ".mysql_error());
header("Location: index.php");
exit();
?>
This is what i have in index.php to recieve the error.
<?php
$error = $_SESSION['error'];
echo "$error";
?>
Please advise how to make this work.
Oh and im coming back to PHP after a long time therefore go easy.
Cheers anyone