if else question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

if else question

Post by hward »

Code: Select all

<?php
elseif ($password == $password2) {
   Passwords didnt match;
     } 
?>
how can I change the == so that ifelse happens when the two passwords
don't match instead of when they do match
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

I'm not sure as what you mean but here's my try

Code: Select all

if ($password == $password2){
//password works
}else{
//password didn't work
}
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

i mean is where == means if the are equal do the state ment is there a if they aren't equal referring to the ==
i am asking is there an oposite to ==
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Operator ! is what your looking for

Code: Select all

$password != $password2 //this means when password is different then password2
But my first code i gave you should work....
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

yea the first code is fine the second what what I am looking for though i think i will give that a try
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

that was what I needed thank you
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

your welcome
:)
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

You can also use if (!$variable)
Post Reply