murdocsvan
Web Programmer
- Messages
- 896
- Location
- Surrey, UK
Basically, i have a form, for creating new users on my database. It just has 3 fields; one for the username; one for the password and one to confirm the user put the right password in. Everything in the form works except comparing the two password fields to make sure they match. I've tested and tried loads of things but if they don't match they still add the user to the database anyway
This is the code for the end of the script:
This is the code for the end of the script:
PHP:
if(empty($username) || empty($password) || empty($confirm_password))
{
echo "Fields are empty";
}
else
{
//?????????????????????????????????????????????????//
//???Problem comparing first and second password???//
//?????????????????????????????????????????????????//
if($password != $confirm_password)
{
echo "New passwords did not match'";
}
else
{
//Turn posted fields into sha1 values
$password = sha1($password);
$confirm_password = sha1($confirm_password);
//Determine what the ID number will be
$sql = "SELECT * FROM $tbl_name";
$result = mysql_query($sql,$con);
$num_rows = mysql_num_rows($result);
$num_rows ++;
//Enter new user into database
$create = "INSERT INTO $tbl_name (id, username, password)
VALUES('$num_rows', '$username', '$password')";
mysql_query($create,$con);
//Take user to Success! page
header("location:****.php");
}
}