使用php(autent.php)中的这些代码说明,我认为一切都很好但是当我登录时,我收到错误:
解析错误:语法错误,第30行中文件autent.php的意外结束
完成php指令后的最后一行是#34; ?> "
<?php
include "connect.php";
/*connect to database with oracle 11g*/
$email = $_GET['username'];
$passw = $_GET['password'];
$query = "SELECT * login WHERE user_email = '$email' AND user_pass= '$passw'";
$sid = oci_parse($conn, $query);
$result = oci_execute($sid);
$dbarray = oci_fetch_array($sid);
if (($email != "") && ($passw != "")) {
if ($dbarray["user_email"] != $email) {
echo "<script> alert('Wrong Email!'); history.back() </script>";
exit;
}
if ($dbarray["user_pass"] != $passw) {
echo "<script> alert('Wrong Password!'); history.back() </script>";
exit;
}
if (($dbarray["user_email"] == $email) && ($dbarray["user_pass"] == $passw)) {
session_start();
$_SESSION["user_email"] = $email;
$_SESSION["user_pass"] = $passw;
switch ($dbarray["type_user_id"]) {
case 1:
header("Location: admin.php");
break;
default:
echo "<script> alert('ERROR:'); history.back() </script>";
exit;
break;
}
} else {
echo "<script> alert('ERROR:'); history.back() </script>";
exit;
}
?>
答案 0 :(得分:1)
你遗漏了FROM
$query = "SELECT * login WHERE user_email = '$email' AND user_pass= '$passw'";
正确的是
$query = "SELECT * FROM login WHERE user_email = '$email' AND user_pass= '$passw'";
你也错过了这里的右括号
}
} else {
echo "<script> alert('ERROR:'); history.back() </script>";
exit;
}
?>
所以正确
if (($email != "") && ($passw != "")) {
if ($dbarray["user_email"] != $email) {
echo "<script> alert('Wrong Email!'); history.back() </script>";
exit;
}
if ($dbarray["user_pass"] != $passw) {
echo "<script> alert('Wrong Password!'); history.back() </script>";
exit;
}
if (($dbarray["user_email"] == $email) && ($dbarray["user_pass"] == $passw)) {
session_start();
$_SESSION["user_email"] = $email;
$_SESSION["user_pass"] = $passw;
switch ($dbarray["type_user_id"]) {
case 1:
header("Location: admin.php");
break;
default:
echo "<script> alert('ERROR:'); history.back() </script>";
exit;
break;
}
}
} else {
echo "<script> alert('ERROR:'); history.back() </script>";
exit;
}