jasonhardwick Posted May 27, 2008 Share Posted May 27, 2008 I've got this code I've been working on and it was working for a while but recently I changed the page and I've lost the functionality of the validate username and password entries. if anyone sees why this stoped working please help... <?php if(isset($_POST['Submit'])){ //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name'])){ header("Location:Messages1.php?msg=17"); exit(); } if( empty($_POST['email'])){ header("Location:Messages1.php?msg=16"); exit(); } if( empty($_POST['pw1']) && (empty($_POST['pw2']))){ header( "Location:Messages1.php?msg=4" ); exit(); } if( empty($_POST['f_name']) && (empty($_POST['l_name']))){ header( "Location:Messages1.php?msg=15" ); exit(); } if( empty($_POST['legal_accept'])){ header( "Location:Messages1.php?msg=14" ); exit(); } $name=$_POST['name']; $email=$_POST['email']; $f_name=$_POST['f_name']; $l_name=$_POST['l_name']; $zip_code=$_POST['zip_code']; $e_private=$_POST['e_private']; $country=$_POST['country']; $bio=$_POST['bio']; $occupation=$_POST['occupation']; $occupation_other=$_POST['occupation_other']; $website=$_POST['website']; $date_joined=date("D, F jS, Y \@ g:i a T"); //create date time $user_image=$_POST['user_image']; $legal_accept=$_POST['legal_accept']; $pw1=$_POST['pw1']; $pw2=$_POST['pw2']; if("$pw1" !== "$pw2" ){ header( "Location:Messages1.php?msg=5" ); exit(); } $ip = $_SERVER['REMOTE_ADDR']; //connect to the db server , check if uname exist include('config.php'); $query=("Select * from user where uname='$name'"); $result= mysql_query($query); $num=mysql_num_rows($result); if( ctype_alnum($pw1) // numbers & digits only && strlen($pw1)>6 // at least 7 chars && strlen($pw1)<21 // at most 20 chars ){ // valid }else{ header( "Location:Messages1.php?msg=12" ); } if( ctype_alnum($name) // numbers & digits only && strlen($name)>6 // at least 7 chars && strlen($name)<21 // at most 20 chars ){ // valid }else{ header( "Location:Messages1.php?msg=13" ); } if ($num > 0) {//Username already exist header( "Location:Messages1.php?msg=6" ); exit(); }else{ //if username does not exist insert user details $query=( "INSERT INTO user (f_name,l_name,zip_code,e_private,country,bio,occupation,occupation_other,website,uname,pw,email,date_joined,user_image,legal_accept,ip,level) VALUES ('$f_name','$l_name','$zip_code','$e_private','$country','$bio','$occupation','$occupation_other','$website','$name','$pw1','$email','$date_joined','$user_image','$legal_accept','$ip','Normal')"); if (@mysql_query ($query)) { header("location:login.php?reg=1"); exit; }else die(mysql_error()); } mysql_close(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/ Share on other sites More sharing options...
Gighalen Posted May 27, 2008 Share Posted May 27, 2008 Did you try changing if("$pw1" !== "$pw2" ){ header( "Location:Messages1.php?msg=5" ); exit(); to if((pw1) == !($pw2) ){ header( "Location:Messages1.php?msg=5" ); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550492 Share on other sites More sharing options...
jasonhardwick Posted May 27, 2008 Author Share Posted May 27, 2008 I feel like my problem is around this part. if( ctype_alnum($pw1) // numbers & digits only && strlen($pw1)>6 // at least 7 chars && strlen($pw1)<21 // at most 20 chars ){ // valid }else{ header( "Location:Messages1.php?msg=12" ); } if( ctype_alnum($name) // numbers & digits only && strlen($name)>6 // at least 7 chars && strlen($name)<21 // at most 20 chars ){ // valid }else{ header( "Location:Messages1.php?msg=13" ); } Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550754 Share on other sites More sharing options...
revraz Posted May 27, 2008 Share Posted May 27, 2008 Which Message do you get, 12 or 13? Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550762 Share on other sites More sharing options...
jasonhardwick Posted May 27, 2008 Author Share Posted May 27, 2008 I dont get either that bit of code doesn't work at all. Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550770 Share on other sites More sharing options...
revraz Posted May 27, 2008 Share Posted May 27, 2008 It's a IF ELSE, something about it has to work or produce an error. Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550813 Share on other sites More sharing options...
jasonhardwick Posted May 27, 2008 Author Share Posted May 27, 2008 Well the rest of my code works... it puts everything in the database and takes me to the successful registration page. It allows anything in the username and pasword fields. Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550822 Share on other sites More sharing options...
revraz Posted May 27, 2008 Share Posted May 27, 2008 Ok, do this, in the line that says: // valid change it to echo "Valid"; exit; Do one for the PW and one for the Name. Echo valid name and valid pw so you can see where it's failing. Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550858 Share on other sites More sharing options...
jasonhardwick Posted May 27, 2008 Author Share Posted May 27, 2008 ok i tried that and nothing...it just passes the data to the database and sends me to my login page... Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550986 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 um...your code says "run the query, then send them to the login page" $query=( "INSERT INTO user (f_name,l_name,zip_code,e_private,country,bio,occupation,occupation_other,website,uname,pw,email,date_joined,user_image,legal_accept,ip,level) VALUES ('$f_name','$l_name','$zip_code','$e_private','$country','$bio','$occupation','$occupation_other','$website','$name','$pw1','$email','$date_joined','$user_image','$legal_accept','$ip','Normal')"); if (@mysql_query ($query)) { header("location:login.php?reg=1"); exit; it's not sending you to login.php?reg=1 ? Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-550990 Share on other sites More sharing options...
revraz Posted May 27, 2008 Share Posted May 27, 2008 I believe it is, he is saying that his validation isnt working. As in he can enter a name/pw less than 7 or greater than 21 or a non alphanumeric character. Quote Link to comment https://forums.phpfreaks.com/topic/107372-specifying-criteria-of-registration-elements/#findComment-551001 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.