Page 1 of 1

comparing a password string

Posted: Fri Feb 03, 2006 2:45 pm
by robster
I've had a look at http://au2.php.net/strcmp and want to basically find out if it's the best way to compare?

I have two variables, $password and $password2 and I want to make sure they're EXACTLY the same, for the password check when a user wants to change their password.

Is that the correct function or is there something better?

Thanks so much, any advice really appreciated,

Rob

Posted: Fri Feb 03, 2006 2:54 pm
by Burrito
if you're comparing it on the server side, why not just use something like:

Code: Select all

<?php
if($_POST['password1'] != $_POST['password2'])
    // some failure processing
else
    // some success processing
?>

Posted: Fri Feb 03, 2006 2:54 pm
by robster
cancel that, it was too easy :)

Code: Select all

//check if they are the same or not
	if ($get_password==$get_password2) {    // This returns true.
	   // $get_password and $get_password2 are the same.
	   echo "passwords are the same<br>";
	} else {
	   // $get_password and $get_password2 are NOT the same.
	   echo "passwords are NOT the same<br>";				   
	}

Posted: Fri Feb 03, 2006 5:29 pm
by Chris Corbyn
Haha.... something smells like C :P