...

View Full Version : Activation not working



ycpc55
08-06-2012, 03:17 PM
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');

AndrewGSW
08-06-2012, 03:32 PM
Is 'actnum' a string?


elseif( $row['actnum'] != '0' )

ycpc55
08-06-2012, 05:52 PM
Thanks a lot for your help works great now.

AndrewGSW
08-06-2012, 05:53 PM
In which case.. :)

$check_password = $hash;

PHP statements are semi-colon terminated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum