onthespot Posted July 4, 2009 Share Posted July 4, 2009 /* Password error checking */ $field = "pass"; //Use field name for password $field2 = "pass2"; // Second field for password if(!$subpass2){ $form->setError($field2, "* Password not entered"); } else{ //Check passwords match $subpass = stripslashes($subpass); $subpass2 = stripslashes($subpass2); if($subpass$subpass2){ $form->setError($field, "* Passwords does not match"); } This is the code for matching passwords on registration. The line if($subpass$subpass2){ seems to be creating a parse error. Any help here would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/ Share on other sites More sharing options...
.josh Posted July 4, 2009 Share Posted July 4, 2009 Maybe it's because you are missing an operator in there? Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868815 Share on other sites More sharing options...
onthespot Posted July 4, 2009 Author Share Posted July 4, 2009 If i am trying to match them, which operator would it be? I considered && or = and that didnt work, still got the "passwords dont match" error, this is the final part to the code and its killing me! Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868819 Share on other sites More sharing options...
.josh Posted July 4, 2009 Share Posted July 4, 2009 that's because && is the 'and' operator, meaning "this and this" and = is the assignment operator. http://us2.php.net/manual/en/language.operators.comparison.php Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868821 Share on other sites More sharing options...
taquitosensei Posted July 4, 2009 Share Posted July 4, 2009 you need to use double equals or triple if you're trying to match data type also. == or === if you use single equals you're setting the value instead of comparing it. Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868822 Share on other sites More sharing options...
mattal999 Posted July 4, 2009 Share Posted July 4, 2009 Change: if($subpass1$subpass2) { To: if($subpass1 !== $subpass2) { == means "is equal to", but the ! before it means "not", so it makes "is not equal to". Read up on operators more though. Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868824 Share on other sites More sharing options...
onthespot Posted July 4, 2009 Author Share Posted July 4, 2009 Ok thankyou, much appreciated. I had a book I was looking into, an I did consider using == and ! but the ! before $subpass. Wouldn't have been correct, i shal try this, thankyou. Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868828 Share on other sites More sharing options...
onthespot Posted July 4, 2009 Author Share Posted July 4, 2009 Works a treat, thankyou all solved Quote Link to comment https://forums.phpfreaks.com/topic/164764-solved-password-match/#findComment-868835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.