ali_2kool2002 Posted April 21, 2007 Share Posted April 21, 2007 Hi can someone tell help me as the code below doesnt check properly if the two variables are the same, it keeps saying they are the same even if the variables are different: <? $choosepass = 'a'; $confirmpass= 'df'; if('$choosepass' == '$confirmpass'){ ?> <script language="Javascript"> alert ( "Passwords must be the same-Please try again") </script> <? } else{ ?> <script language="Javascript"> alert ( "Passwords same") </script> <? } ?> Link to comment https://forums.phpfreaks.com/topic/48017-solved-equality-of-two-fields/ Share on other sites More sharing options...
obsidian Posted April 21, 2007 Share Posted April 21, 2007 You are checking to see whether the literal strings '$choosepass' and '$confirmpass' are equivalent, which they will never be. Get rid of the single quotes, and you'll be alright: <?php if ($choosepass == $confirmpass) { // they're equal ?> Link to comment https://forums.phpfreaks.com/topic/48017-solved-equality-of-two-fields/#findComment-234683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.