I have the following code:
if(strcmp($_POST['password'], $_POST['password-rpt']) == 0) {
$password_field = $_POST['password'];
echo "Password created" . "<br />";
} else {
echo "blarg! Password mismatch!!!";
}
I know that like C/C++ strcmp is supposed to return 0 when the two strings are the same but when I test it with an html file, entering two identical strings or two different ones, both cases go to the error case and my output is "blarg! Password mismatch!!!"
Here is the form I used:
<form method="post" action="register.php">
Name: <input type="text" name = "name" id="name" /><br />
Password: <input type="password" name ="password" id = "password" /> <br />
Confirm Password: <input type="password" name="password_rpt" id="password_rpt" /> <br />
email: <input type="text" name = "remail" id = "remail" /><br />
<input type = "submit" name="register" id="register" value = "Sign Up" />
</form>
What am I missing?
Update:
I changed the condition to if($_POST['password'] == $_POST['password-rpt'])
. Hasn't helped.