I would like to display a message ($msg) saying that the account has not been activated yet and another one with Invalid Username or Password. In the example below, ($msg) includes both messages, and I want to split in two, depending on the result. Thank you so much for your precious help.
Here is the code:
<?php
session_start();
include_once ("include/configure.php");
include_once ("include/dbconnection.php");
$msg = "";
if (isset($POST['submit']))
{
$username = $POST['username'];
$password = $POST['password'];
$remember = $POST['remember'];
$sql = mysql_query("SELECT * FROM users WHERE username='" . $username . "' AND password='" . $password . "' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$SESSION['s_logged_n'] = 'true';
$SESSION['s_username'] = $username;
$_SESSION['s_lastname'] = $row['lastname'];
mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
header("Location: login_success.php");
if(isset($_POST['remember'])){
setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
}
}
}
else {
$msg = "Invalid username or password, or you haven't activated your account!";
}
}
?>