我已经将我的网站从本地移动到了liv服务器上的子域,我在登录脚本方面遇到了一些问题,我们都在本地完成了工作,但似乎会议因为在线移动而无法正常工作。 / p>
所以我的脚本如下所示:
<?php
session_start();
include_once '../config.php';
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
$query = "SELECT user_email, user_password FROM users WHERE (user_email = '". $email ."')";
$result = $conn->query($query);
if ($result->num_rows === 1) {
$row = $result->fetch_array(MYSQLI_ASSOC);
if (password_verify($password, $row['user_password'])) {
$_SESSION['user_id'] = $row[ 'user_id' ];
$_SESSION['user_email'] = $row[ 'user_email' ];
$_SESSION['video_1_status'] = $row[ 'video_1_status' ];
$_SESSION['video_2_status'] = $row[ 'video_2_status' ];
$_SESSION['video_3_status'] = $row[ 'video_3_status' ];
$_SESSION['video_4_status'] = $row[ 'video_4_status' ];
header('Location: ../home.php');
} else{
header('Location: ../login.php?message=Email address or password is incorrect');
}
} else{
header('Location: ../login.php?message=Email address or password is incorrect');
}
$conn->close();
?>
如此简单明了没有技巧,但是当我传递这些值时,它会给我带来一些错误:
Notice: Undefined index: user_id in /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php on line 17
Notice: Undefined index: video_1_status in /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php on line 20
Notice: Undefined index: video_2_status in /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php on line 21
Notice: Undefined index: video_3_status in /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php on line 22
Notice: Undefined index: video_4_status in /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php on line 23
Warning: Cannot modify header information - headers already sent by (output started at /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php:17) in /var/sites/r/reedvid.mydomain.co.uk/public_html/actions/login-action.php on line 25
很清楚它告诉我的是什么,但我不完全确定A:为什么这在本地工作而B:出了什么问题?
答案 0 :(得分:0)
确保在php.ini中的网络服务器上正确保存会话。
您还可以尝试通过打印session_id();