SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2003
    Location
    Temecula, CA
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Activation problem -- again

    When a user (for now me) registers for access, an email is automatically sent to have the person confirm registration and a temp password is given. From the auto-email when the link is clicked to activate account; I get "Your account could not be activated." BUT in the database the "set activate 1" has happened, and if I manually go to the login.html page I can access.

    Any ideas why the below, activates the account BUT does not 'realize' that the account has been activated and send you to the login page?

    PHP Code:
    <?
    /* 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 "SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'";
    $result=mysql_query($sql_doublecheck)or die("SQL Error: ".mysql_error()."<br>File: ".__FILE__."<br>Line: ".__LINE__); 

    //$doublecheck = mysql_num_rows($result);

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

    ?>
    I DID make sure that the database was updated to "activated 1".

  2. #2
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Raleigh, NC
    Posts
    783
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're running your if statement on the sql query string itself, not your results

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2003
    Location
    Temecula, CA
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just thought, would changing
    PHP Code:
    elseif ($sql_doublecheck 0) { 
        echo 
    "<strong>Your account has been activated!</strong> You may login below!<br />"
        include 
    'login_form.html'

    to
    PHP Code:
    elseif ($sql_doublecheck == 1) { 
        echo 
    "<strong>Your account has been activated!</strong> You may login below!<br />"
        include 
    'login_form.html'

    make a difference? I don't think it should matter if I tell the sys to look for greater than 0 or equals to 1.

    Am I wrong, does it make a difference?
    Thanks

  4. #4
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Raleigh, NC
    Posts
    783
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your if statement's structure was correct, however $sql_doublecheck is still your sql query string. so:
    elseif ($sql_doublecheck == 1)
    says:
    elseif ("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'" == 1)
    which of course it does not

    uncomment your $doublecheck line and run the if statement on $doublecheck

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2003
    Location
    Temecula, CA
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your paitence and help.
    your if statement's structure was correct, however $sql_doublecheck is still your sql query string. so:
    elseif ($sql_doublecheck == 1)
    says:
    elseif ("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'" == 1)
    which of course it does not

    uncomment your $doublecheck line and run the if statement on $doublecheck
    I changed the if and elseif statements to $doublecheck and now it works perfectly.

    Thank you again
    Josh

  6. #6
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Raleigh, NC
    Posts
    783
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no problem. easy one to overlook - happens to the best of us


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •