Php 页面在登录时不接受用户,即使用户有效

Php 页面在登录时不接受用户,即使用户有效,php,authentication,login,dreamweaver,Php,Authentication,Login,Dreamweaver,我一直有一些问题,关于用户登录功能的网站上,我正在做的时刻。我在index.php页面上创建了一个登录表单表,并告诉它,如果登录有效,则转到userindex.php;如果登录无效,则转到loginfail.html。然后,我使用dreamweavers页面授权工具保护页面userindex.php,并告诉它将未经授权的用户重定向回index.php 我遇到的问题是,一旦有人输入正确的用户名和密码详细信息并按submit,他们就会被发送到index.php。这就好像它们被发送到userindex

我一直有一些问题,关于用户登录功能的网站上,我正在做的时刻。我在index.php页面上创建了一个登录表单表,并告诉它,如果登录有效,则转到userindex.php;如果登录无效,则转到loginfail.html。然后,我使用dreamweavers页面授权工具保护页面userindex.php,并告诉它将未经授权的用户重定向回index.php

我遇到的问题是,一旦有人输入正确的用户名和密码详细信息并按submit,他们就会被发送到index.php。这就好像它们被发送到userindex.php,然后未经授权。但是,在登录后,键入userindex.php的地址将显示包含用户信息的完整页面,就好像他们已经被批准一样

以下是关于此用户登录问题的两个页面的代码

index.php

    <?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['UsernmaeBox'])) {
          $loginUsername=$_POST['UsernmaeBox'];
          $password=$_POST['PasswordBox'];
          $MM_fldUserAuthorization = "";
          $MM_redirectLoginSuccess = "Userindex.php";
          $MM_redirectLoginFailed = "loginfail.html";
          $MM_redirecttoReferrer = false;
          mysql_select_db($database_dbname, $dbname);

          $LoginRS__query=sprintf("SELECT Username, Password FROM SGUsers WHERE Username=%s AND Password=%s",
            GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

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

            if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
            //declare two session variables and assign them
            $_SESSION['MM_Username'] = $loginUsername;
            $_SESSION['MM_UserGroup'] = $loginStrGroup;       

            if (isset($_SESSION['PrevUrl']) && false) {
              $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
            }
            header("Location: " . $MM_redirectLoginSucenter code here      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

这里有两种可能的打字错误。您使用的是UsernmaeBox而不是UsernameBox。除非你是故意的

if (isset($_POST['UsernmaeBox'])) {
      $loginUsername=$_POST['UsernmaeBox'];

这是很多登录代码,甚至没有sql注入陷阱。不管怎样,为什么不试着注释掉
标题(“位置:”.$MM\u restrictGoTo)
并尝试回显sessions变量以检查它们是否包含任何值。如果它们保存了必要的值,那么您的if登录检查器有问题。太好了,我来看看。谢谢
if (isset($_POST['UsernmaeBox'])) {
      $loginUsername=$_POST['UsernmaeBox'];