On Wed, 26 Jul 2006 13:54:15 +0200, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote: > php@xxxxxxxxx wrote: >> >> >> On Wed, 26 Jul 2006 13:22:02 +0200, Jochem Maas <jochem@xxxxxxxxxxxxx> > wrote: >>> php@xxxxxxxxx wrote: >>>> Hi >>>> I am reading a username and password from a file. For the moment I am >>> trying to test if the username and password are the same as user > inputted >>> username/password. >>>> My code snippet is as follows: >>>> if( $out[0][0] == $u && $out[0][1] == $p ) { >>> >>> >>>> $error = "Login successful!"; >>>> } >>>> else { >>>> $error = "Invalid username/password. Try again"; >>>> } >>>> >>>> $out[] is an array containing the file data. >>>> $u is the form username and $p the password. >>>> I echo both values once submitted. Even when they match I get invalid >>> username/password message. >>>> If I just test if( $out[0][1] == $u ) it works. >>> take a REALLY GOOD LOOK at your [compound] if statement >>> (hint: what are you checking against $out[0][1]?) >> >> Sorry, that was a typo. > > I'm sure it was; and I'm sure that you have lots of typos. huh? > here is test code that proves that if what you say it true regarding > the contents/structure of $out, $u and $p then when the relevant values > match you > will get the "Login Successful!" message; seeing as you are not it means > you > are testing the wrong variables or something: > > // CODE > $out = array(array("user","pwd")); $u = "user"; $p = "pwd"; > if($out[0][0] == $u && $out[0][1] == $p) { > echo "Match\n"; > } else { > echo "No Match!"; > } > // OUTPUT > //Match! > > >> $out[0][1] is the password. Should have read: >> if( $out[0][1] == $p ) >> So that works, once i add the && $out[0][0] == $u >> it no longer works, even though my echo shows both values are the > same... > > do you know the difference between print_r(), var_dump() and echo? > try: > > var_dump($out, $u, $p, (" user " == "user")); Thanks, I will try your suggestions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php