-2
我已經將我的網站從本地移動到liv服務器上的子域,並且在我的登錄腳本週圍出現了一些問題,它在本地完美工作,但似乎會話不起作用我預計自移動在線。
所以我的腳本如下所示:
<?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:什麼是錯的?
您沒有在查詢中選擇video_statuses,您只選擇了user_email,並且僅輸入了密碼 –