Jump to content


Photo

What is making it so that the this else statment is appearing?


  • Please log in to reply
3 replies to this topic

#1 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 15 October 2006 - 08:03 PM

I am creating a membership and got it so that someone can register and the info goes to a database.. after that they recieve an email and are given a link to click to activate their account. Heres the acivate.php file.
<? 
/* Account activation script */ 

// 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 />"; 
    include 'login.php'; 
} 

?>
For some reason everytime I do it, it will say "Your account could not be activated!". And I can see that in the if else statment its double checking to make sure that the activated cell in the table on my database is set to 1, but why isn't is setting it to 1? That's why I'm getting the error? Would you happen to know why? I'm connecting to the database and everything okay, is there something wrong with this script? Any help would be great!

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 15 October 2006 - 08:36 PM

Do you get any errors returned when altering this line:
$sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'") or die(mysql_error());


#3 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 15 October 2006 - 08:49 PM

i dont understand....

#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 16 October 2006 - 03:08 AM

i replaced that line with that and it still wont go through




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users