Jump to content

Why Arent The Fields Changing?


IT-Guy

Recommended Posts

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";
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/91461-why-arent-the-fields-changing/
Share on other sites

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";
}
?>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.