This log in script was working fine, now it’s not.
It says “you must activate…” even for accounts that are already activated (checked database)
print_r($row) shows nothing.
Any ideas?[php]session_start();
require_once(“db_connect.php”);
<?
if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
header("Location: https://www.caregivingsocal.com/members.php");
}
if(isset($_POST['submit'])) {
if(!$_POST['username']) die("Error: You must enter your username to log in.");
if(!$_POST['password']) die("Error: You must enter a password to log in.");
//set cookie if checked
if(!empty($_POST['stay_in'])) {
$joined =''.$_POST['username'].'[]'.md5($_POST['password']).'';
setcookie('login_cookie', $joined, 2147483647, '/','www.caregivingsocal.com');
} // end if
//verify user
$get_user = mysql_query("SELECT * FROM mem WHERE username = '".$_POST['username']."' AND user_password = '".md5($_POST['password'])."'");
$q = mysql_fetch_object($get_user);
if(!$q) die("Login Failure: Please verify your username and password are correct." . mysql_error());
$row = mysql_fetch_array($get_user);
if ($row['activated'] == 0) {
?>
Sorry, you must activate your account first!
Didn't get your validation email? Click here to resend the validation email.
<?
die();
}
// set session variables
$_SESSION[‘logged_in’] = 1;
$_SESSION[‘username’] = $_POST[‘username’];
$_SESSION[‘password’] = $_POST[‘password’];
session_write_close();
Header(“Location: https://www.caregivingsocal.com/signin.php”);
} else {
//show login form
?>
Username: |
|
Password: |
|
Submit: |
Remember Me |
<?
} // end else
?>[/php]
MOD EDIT: Changed code to php tags for readability