doqp87012 2016-08-07 23:24
浏览 46

登录页面返回Request-URI太长,Dreamweaver $ MM_restrictGoTo =“login.php”错误

I am trying to setup a login page with different user level. I am working from this SimpleTut Tutorial on How to build a User Registration System - Registration, Login, Email Password, Update, Admin Backend https://www.youtube.com/watch?v=Qqcj4nYkcks.

I notice that the code written with Databases, Binding and Server Behaviour gives alot of problem especially with mysqli.

        <?php require_once('Connections/localhost.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

    {
    /*Global variable $con is necessary, because it is not known inside the function and you need it for mysqli_real_escape_string($connection, $theValue); the Variable $con ist defined as mysqli_connect("localhost","user","password", "database") with an include-script.
    */

      Global $connection;
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
      $theValue = mysqli_real_escape_string($connection, $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;
    }
    }

    //mysql_select_db($database_localhost, $localhost);
      $errorr = "You have an issue with the connection.";
      $connection = mysqli_connect ("localhost", "root", "", "yardiemovie");
    $query_Login = "SELECT * FROM yardiecustomers";
    /* $Login = mysql_query($connection, $query_Login) or die(mysql_error($connection));
    $row_Login = mysql_fetch_assoc($Login);
    $totalRows_Login = mysql_num_rows($Login) */
    ?>
    <?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['username'])) {
      $loginUsername=$_POST['username'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "UserLevel";
      $MM_redirectLoginSuccess = "account.php";
      $MM_redirectLoginFailed = "login.php";
      $MM_redirecttoReferrer = true;
      $connection = mysqli_connect ("localhost", "root", "", "yardiemovie");

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

      $error = "You have an issue with the connection."; 
      $LoginRS = mysqli_query($connection, $LoginRS__query) or die(mysql_error(error));
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {

        $loginStrGroup  = mysql_result($LoginRS,0,'UserLevel');


        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']) && true) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
        }
        header("Location: " . $MM_redirectLoginSuccess );
      }
      else {
        header("Location: ". $MM_redirectLoginFailed );
      }
    }

    $MM_authorizedUsers = "1";
    $MM_donotCheckaccess = "false";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
      // For security, start by assuming the visitor is NOT authorized. 
      $isValid = False; 

      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
      // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
      if (!empty($UserName)) { 
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
        // Parse the strings into arrays. 
        $arrUsers = Explode(",", $strUsers); 
        $arrGroups = Explode(",", $strGroups); 
        if (in_array($UserName, $arrUsers)) { 
          $isValid = true; 
        } 
        // Or, you may restrict access to only certain users based on their username. 
        if (in_array($UserGroup, $arrGroups)) { 
          $isValid = true; 
        } 
        if (($strUsers == "") && false) { 
          $isValid = true; 
        } 
      } 
      return $isValid; 
    }

        $MM_restrictGoTo = "login.php";
            if (!((isset($_SESSION['MM_Username'])&& true) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
          $MM_qsChar = "?";
          $MM_referrer = $_SERVER['PHP_SELF'];
          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;
    }
    ?>

Can someone say whats happening? This is normally the result. http://localhost:8080/MovieRentalSite/login.php?accesscheck=%2FMovieRentalSite%2Flogin.php%3Faccesscheck%3D%252FMovieRentalSite%252Flogin.php%253Faccesscheck%253D%25252FMovieRentalSite%25252Flogin.php%25253Faccesscheck%25253D%2525252FMovieRentalSite%2525252Flogin.php%2525253Faccesscheck%2525253D%252525252FMovieRentalSite%252525252Flogin.php%2......525252525252525252525252525252525252Flogin.php

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集