Page 1 of 1

login failed message

Posted: Fri Feb 27, 2009 8:49 am
by dheeraj
hello guys, here i have a login form & i want to throw a message as the login failed, please any one help me to do this, below is the login code (made by using dreamweaver)

Code: Select all

<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}
 
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
 
if (isset($_POST['text'])) {
  $loginUsername=$_POST['text'];
  $password=$_POST['text2'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "profile.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_apnahome, $apnahome);
  
  $LoginRS__query=sprintf("SELECT username, password FROM register WHERE username='%s' AND password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $apnahome) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;       
 
    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {  
    header("Location: ". $MM_redirectLoginFailed );     
  }
}
?>