Account activation PHP

Posted by Wayne on Stack Overflow See other posts from Stack Overflow or by Wayne
Published on 2010-06-09T23:51:09Z Indexed on 2010/06/10 0:02 UTC
Read the original article Hit count: 262

Filed under:
|
|

I created this account registration activation script of my own, I have checked it over again and again to find errors, I don't see a particular error...

The domain would be like this:

http://domain.com/include/register.php?key=true&p=AfRWDCOWF0BO6KSb6UmNMf7d333gaBOB

Which comes from an email, when a user clicks it, they get redirected to this script:

if($_GET['key'] == true)
{
    $key = $_GET['p'];

    $sql = "SELECT * FROM users
            WHERE user_key = '" . $key . "'";

    $result = mysql_query($sql) or die(mysql_error());

    if(mysql_affected_rows($result) > 0)
    {
        $sql = "UPDATE users
                SET user_key = '', user_active = '1'
                WHERE user_key = '" . $key . "'";

        $result = mysql_query(sql) or die(mysql_error());

        if($result)
        {
            $_SESSION['PROCESS'] = $lang['Account_activated'];
            header("Location: ../index.php");
        }
        else
        {
            $_SESSION['ERROR'] = $lang['Key_error'];
            header("Location: ../index.php");
        }
    }
    else
    {
        $_SESSION['ERROR'] = $lang['Invalid_key'];
        header("Location: ../index.php");
    }
}

It doesn't even work at all, I looked in the database with the user with that key, it matches but it keeps coming up as an error which is extremely annoying me. The database is right, the table and column is right, nothing wrong with the database, it's the script that isn't working.

Help me out, guys.

Thanks :)

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql