PDA

View Full Version : HELP... my activation isn't workin



nvzak
January 25th, 2006, 12:28 AM
OK, i have built a client login and yet when i test it the activation doesn't work. Heres the URL http://client.cyhite.com/login/join_form.php. Here's the code for the activate page


<?
// Get database connection
include 'db.php';

// Create variables from URL.

$userid = $_REQUEST['id'];
$code = $_REQUEST['code'];

$sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'");

$sql_doublecheck = mysql_query("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'");
$doublecheck = mysql_num_rows($sql_doublecheck);

if($doublecheck == 0){
echo "<strong><font color=red>Your account could not be activated!</font></strong>";
} elseif ($doublecheck > 0) {
echo "<strong>Your account has been activated!</strong> You may login below!<br />";
}

?>
I use the double check in all of my user management systems and so i dont think its that but, i could be rong, let me in on your thoughts.

Sorry if I miss posted in the client side section...

nobody
January 25th, 2006, 12:50 AM
Moved this to Serverside where it belongs :)

FreakSheep
January 25th, 2006, 01:45 AM
use mysql_affected_rows instead. if any row had been changeed, itll return 1(or how ever many rows wre affteced)


<?
// Get database connection
include 'db.php';

// Create variables from URL.

$userid = $_REQUEST['id'];
$code = $_REQUEST['code'];

$sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'");


if(!mysql_affected_rows($sql) > 0){
echo "<strong><font color=red>Your account could not be activated!</font></strong>";
}else{
echo "<strong>Your account has been activated!</strong> You may login below!<br />";
}

?>

made that really quick, might be a typo in it though :)


_naaman