comparing a password string

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

comparing a password string

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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
?>
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post 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>";				   
	}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Haha.... something smells like C :P
Post Reply