IT-Guy Posted February 17, 2008 Share Posted February 17, 2008 I have a validation script - Users register > then they are sent a link to click > Once they click the link their 'validation' field in the database changes from a 0 to a 1. ( 1 = Meaning their account is activated ) I also have a field called accesslevel in the table, and up on clicking the validation link I also want this field to change from a 0 to a 1. For some reason right now its not changing, but I cannot seem to pin-point where the error is in the code - Was curious if anyone could see any errors or had any advice: <?php if( mysql_num_rows($res) == 1 ) { print "Account activated!\n"; @mysql_query("UPDATE users SET activated=1 WHERE uid = '$uid'"); } else { print "Account not found"; } ?> This isn't the whole code just part of it, this is the part where it changes the activated field from 0 to 1, so if I want to accesslevel field changed from 0 to 1 as well I need to make the code look like this dont I? <?php if( mysql_num_rows($res) == 1 ) { print "Account activated!\n"; @mysql_query("UPDATE users SET `activated`=1,`accesslevel`=1 WHERE uid = '$uid'"); } else { print "Account not found"; } ?> Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Check to make sure your sql is working right: <?php if( mysql_num_rows($res) == 1 ) { print "Account activated!\n"; mysql_query("UPDATE `users` SET `activated`='1',`accesslevel`='1' WHERE `uid` = '$uid'") or die(mysql_error()); } else { print "Account not found"; } ?> Quote Link to comment Share on other sites More sharing options...
IT-Guy Posted February 17, 2008 Author Share Posted February 17, 2008 Ok, I edited the script so that it is changing the 'accesslevel' field now. Now the reason I wanted the accesslevel field changed to a 1 is because when a user trys to login and the php script checks the 'accesslevel' and sees the 1 the php script directs the user to a certain URL. So now Im working on the login script. After registering and clicking the activation link Im trying to login with the username and password it sends me and Im getting a ' ''Username Does not Exist'' I dont think the php script is checking the 'uid' field (uid = is the username field) I dont think the script is checking the UID field, but I can't figure out why: $SQL = "SELECT * FROM `users` WHERE uid = '".$username."' LIMIT 1"; $QUERY = mysql_query($SQL) or die(mysql_error()); if(mysql_num_rows == 0) { $error[] = "Your username doesnt exist"; Any suggestions? Quote Link to comment 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.