lukelee Posted December 4, 2008 Share Posted December 4, 2008 Here is my code, there are 3 inputs, username, password and repeat_password, both of them cant be null, and password must be same as repeat_password. otherwise, shows error message. but my code doesnt work, i think there must be something wrong in if condition. $username = $_POST[username]; $password = $_POST[password]; $repeat_password = $_POST[repeat_password]; if(($username && $password && $repeat_password!= 0) && ($password==$repeat_password || $password)) { $query = mysql_query("UPDATE admin SET username='$username',passwd='$password' where id='1'"); echo "detail has been changed, you will be redirecting to previous page in 3 seconds"; } else { echo "ERROR..... please check the contents you have entered."; Link to comment https://forums.phpfreaks.com/topic/135459-simple-question-on-regester-validator/ Share on other sites More sharing options...
TankedShark Posted December 4, 2008 Share Posted December 4, 2008 Try this instead: <?php $username = $_POST[username]; $password = $_POST[password]; $repeat_password = $_POST[repeat_password]; if(($username && $password && $repeat_password != null) && ($password == $repeat_password || $password)) { $query = mysql_query("UPDATE admin SET username='$username',passwd='$password' where id='1'"); echo "detail has been changed, you will be redirecting to previous page in 3 seconds"; } else { echo "ERROR..... please check the contents you have entered."; } ?> You may also want to add additional checks for the validity of the inputs. Minimum length, proper character types, etc. Right now they'll take anything, like a single space. Link to comment https://forums.phpfreaks.com/topic/135459-simple-question-on-regester-validator/#findComment-705720 Share on other sites More sharing options...
lukelee Posted December 4, 2008 Author Share Posted December 4, 2008 done, thanks a lot. Link to comment https://forums.phpfreaks.com/topic/135459-simple-question-on-regester-validator/#findComment-705722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.