我正在使用angularJS和PHP后端应用程序,我设法应用身份验证,但在应用会话时,我收到此错误:未定义的索引:select.php文件中的标记。我该如何解决这个问题呢!
的login.php
<?php
session_start();
$data = json_decode(file_get_contents("php://input"));
$connect = mysqli_connect("localhost", "root", "", "test");
if (count($data) > 0) {
$Email = mysqli_real_escape_string($connect, $data->Email);
$password = mysqli_real_escape_string($connect, $data->password);
$query = 'SELECT * FROM `client` WHERE (EmailClient = "' . $Email . '" AND password= "' . $password . '")';
$q = mysqli_query($connect, $query);
if (mysqli_num_rows($q) > 0) {
$token = md5($Email . time() . "51395+81519851");
$query = "UPDATE client SET token = '" . $token . "' WHERE EmailClient = '" . $Email . "'";
mysqli_query($connect, $query);
$_SESSION["logged_in"] = true;
$_SESSION["token"] = $token;
$result['message'] = 'Logged In';
$result['email'] = $Email;
$result['token'] = $token;
$resultstring = json_encode($result);
$resultstring = str_replace("null", '""', $resultstring);
echo $resultstring;
exit;
}
$result['message'] = 'The username or password are incorrect!';
$resultstring = json_encode($result);
$resultstring = str_replace("null", '""', $resultstring);
echo $resultstring;
exit;
}
?>
select.php
<?php
session_start();
$connect = mysqli_connect("localhost", "root", "", "test");
$output = array();
$query = "SELECT Name,Adresse FROM client WHERE token = '" . $_SESSION['token'] . "'";
$result = mysqli_query($connect, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$output[] = $row;
}
echo json_encode($output);
}
?>
提前致谢