...

View Full Version : Check if account is activated



ycpc55
07-31-2012, 06:29 AM
Hi,
I'm having a little problem checking to see if a account has been activated or not. I don't know if i'm on the right track or not, here is what i got and what im trying to add. First is my login script, and second is what im trying to add to check if the account has been activated. Any help would be great thanks.

Login script:

session_start();
include_once("db.php");
$errors = array();
if(isset($_POST["iebugaround"])){
$uname = trim(htmlentities($_POST['username']));
$passw = trim(htmlentities($_POST['password']));
if (empty ($uname) || empty ($passw)) {
$errors[] = "$required_fields";
}
if(!$errors){
$passencrypt = hash('sha512', $_POST['password']);
$query = "SELECT * FROM members WHERE username='".mysql_real_escape_string($uname)."' AND password='".mysql_real_escape_string($passencrypt)."'";
$result = mysql_query($query) OR die(mysql_error());
$result_num = mysql_num_rows($result);
if($result_num > 0){
while($row = mysql_fetch_array($result)){
$idsess = stripslashes($row["id"]);
$username = stripslashes($row["username"]);
$_SESSION["SESS_USERID"] = $idsess;
$_SESSION["SESS_USERNAME"] = $username;
setcookie("userloggedin", $username);
setcookie("userloggedin", $username, time()+43200);
header("Location: users-area.php");
exit();
}
} else {
$errors[] = "$incorrectLogin";
}
}
}
Code trying to add:

if ($row["actnum"] == "0"){
//Then login to site
}else{
$errors[] = "$accountNotActivated";
}

Arcticwarrio
07-31-2012, 12:39 PM
try:


<?php
session_start();
include_once("db.php");
$errors = array();
if(isset($_POST["iebugaround"])){
$uname = mysql_real_escape_string(trim(htmlentities($_POST['username'])));
$passw = mysql_real_escape_string(trim(htmlentities($_POST['password'])));
if (empty ($uname) || empty ($passw)) {
$errors[] = "$required_fields";
}else{
$passencrypt = hash('sha512', $_POST['password']);
$query = "SELECT * FROM members WHERE username='".$uname."' AND password='".$passencrypt."'";
$result = mysql_query($query) OR die(mysql_error());
$result_num = mysql_num_rows($result);
}
if ($row["actnum"] == "0"){
//Then login to site
}else{
$errors[] = "$accountNotActivated";
}

if(!$errors){
if($result_num > 0){
while($row = mysql_fetch_array($result)){
$idsess = stripslashes($row["id"]);
$username = stripslashes($row["username"]);
$_SESSION["SESS_USERID"] = $idsess;
$_SESSION["SESS_USERNAME"] = $username;
setcookie("userloggedin", $username);
setcookie("userloggedin", $username, time()+43200);
header("Location: users-area.php");
exit();
}
} else {
$errors[] = "$incorrectLogin";
}
}
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum