请帮帮我。我每次登录都会出现这个错误。-"此网页有一个重定向循环ERR_TOO_MANY_DIRECTS"请帮帮我,我会非常感谢你的帮助。谢谢
这是我的index.php
<?php
include('login.php'); // Includes Login Script
?>
这是我的login.php
<?php
session_start();
$error = "";
if (isset($_POST['submit'])) {
if (empty($_POST['email']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
} else {
// Define $username and $password
$usernameLogin = $_POST['email'];
$passwordLogin = $_POST['password'];
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysql_connect("localhost", "apple", "Apple318992");
// To protect MySQL injection for Security purpose
$username = stripslashes($usernameLogin);
$password = stripslashes($passwordLogin);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
// Selecting Database
$db = mysql_select_db("TS", $connection);
// SQL query to fetch information of registerd users and finds user match.
$query = mysql_query("select * from Users where password='$password' AND email='$usernameLogin'", $connection);
$rows = mysql_num_rows($query);
if ($rows == 1) {
$_SESSION['login_user'] = $usernameLogin; // Initializing Session
} else {
$error = "Username or Password is invalid";
}
}
}
if (isset($_SESSION["login_user"])) {
header("Location:timesheets.php");
}
?>
这是我的会话.php
<?php
include ('DBConnect.php');
session_start(); // Starting Session
// Storing Session
$user_check = $_SESSION['login_user'];
// SQL Query To Fetch Complete Information Of User
$ses_sql = mysql_query("select email from Users where email='$user_check'", $conn);
$row = mysql_fetch_assoc($ses_sql);
$login_session = $row['email'];
if (!isset($login_session)) {
mysql_close($conn); // Closing Connection
header('Location: index.php'); // Redirecting To Home Page
}
?>
而不是:标头('Location:index.php')
尝试使用javascript:
echo'<script>document.location。href="index.php"<脚本>'
在您的session.php中,您必须销毁会话,因为它可能被设置为静止,但如果没有它,查询可以找到现有用户?
要取消设置会话,请执行以下操作:
用于特定会话的所有会话变量CCD_ 2的CCD_
请将其放在重定向到index.php.之前
否则我不知道该怎么帮你对不起。
您是否启用了php错误/调试?通常为session_start();如果我是正确的,应该在php文件的第一行,否则会引发错误。