1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

activation not working

Discussion in 'PHP' started by ycpc55, Aug 5, 2012.

  1. #1
    Hi,
    i was wondering if anyone had any idea how to fix this problem im having? My problem is the activation part of the code its not working at all. If the member did not activate there account it will still let them login. Here is some info on how i have it in the database. In the database when the member creates an account, it will also create a generated activation code for that account. Also if the member activates there account it will set it to 0 in the database. Any help would be great thanks.

    require("db.php");
    $submitted_user = '';
    $errormessage = '';
    if(!empty($_POST))
    {
        $query = "SELECT id,user,password,salt,actnum FROM users WHERE user = :user";
        $query_params = array(
        ':user' =>  $_POST['user']
        );
        try
        {
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }
        catch(PDOException $ex)
        {
            die("Failed to run query: " . $ex->getMessage());
        }
        $login_ok = false;
        $row = $stmt->fetch();
        if($row)
        {
            $check_password = hash('sha256', $_POST['password'] . $row['salt']);
            if($check_password === $row['password'])
            {
                $login_ok = true;
            }
        }
        if( !$login_ok ) {
            $errormessage = "User ID/password mismatch";
    ////////Activation code/////////////
            } elseif( $row['actnum'] != 0 ) {
            $errormessage = "Account not activated";
    /////////////////////////////////////////////////////////
            } else {
            unset($row['salt']);
            unset($row['password']);
            $_SESSION['user'] = $row;
            header("Location: users");
        }
    }
    $submitted_user = htmlentities($_POST['user'], ENT_QUOTES, 'UTF-8');
    PHP:

     
    ycpc55, Aug 5, 2012 IP