登录页面什么都不做

时间:2018-06-23 17:14:42

标签: php

请,我有一个登录页面的代码,除了它似乎无法正常工作外,这意味着当我输入正确的用户名和密码并单击“登录”时,表单会重新加载并停留在相同的登录页面。如果有人可以提出一些可能很好的解决方案,那对PHP来说还很陌生,到目前为止还没有运气解决此问题。这是我的代码:

<?php require_once('../Connections/conexao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?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['login'])) {
  $loginUsername=$_POST['login'];
  $password=$_POST['senha'];
  $MM_fldUserAuthorization = "id_nivel";
  $MM_redirectLoginSuccess = "base.php";
  $MM_redirectLoginFailed = "index.php";
  $MM_redirecttoReferrer = false;

  mysql_select_db($tabela, $con);

  $LoginRS__query=sprintf("SELECT id_usuario, login, senha, id_nivel FROM usuarios WHERE login=%s AND senha=password('$password') AND activo = 1",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

  $LoginRS = mysql_query($LoginRS__query, $con) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {

    $loginStrGroup  = mysql_result($LoginRS,0,'id_nivel');
    $loginStrId     = mysql_result($LoginRS,0,'id_usuario');

    //declare two session variables and assign them
    $_SESSION['MM_Username']    = $loginUsername;
    $_SESSION['MM_UserGroup']   = $loginStrGroup;
    $_SESSION['MM_UserId']      = $loginStrId;        

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Locbat - Website Management</title>
<link rel="shortcut icon" href="../imagens/empresas/locbat_icon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript">
function setfocus(){
    document.getElementById('login').focus();
};
</script>
<body onload="setfocus();">
<div id="box">

  <div id="header">
     <div id="header_logo">
    </div><!--header logo--> 

  </div>

  <div id="painel_de_login">
   <div class="alert">
 </div>

     <form method="POST" action="<?php echo $loginFormAction; ?>" name="login_erro">
      <fieldset>
        <legend>Efectue a autenticação</legend>
       <label>
         <span>Utilizador</span>
          <input type="text" name="login" id="login" />
        </label>

        <label>
         <span>Password</span> 
          <input type="password" name="senha" id="senha" />
        </label>

        <input type="submit" name="logar" value="entrare" class="login_btn"/>

       </fieldset>
     </form>   
   <span style="color:#FFF; text-align:right" ><a href="forgot_password.php">Esqueci a senha!</a></span>
   </div><!-- Painel de login-->

</div>

</body>
</html>

0 个答案:

没有答案