我希望我的登录页面只有一个字段,但我的index.php上显示错误 这是我的index.php页面:
<?php include('supsrwk_epenyenggaraan.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6)`{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) `{case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";break; case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;} return $theValue;
}`}`
$colname_maklumatkuarter = "-1";
if (isset($_SESSION['No_KP']))
$colname_maklumatkuarter = $_SESSION['No_KP'];
}
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$query_maklumatkuarter = sprintf("SELECT * FROM maklumatkuarter WHERE No_KP = %s", GetSQLValueString($colname_maklumatkuarter, "text"));
$maklumatkuarter = mysql_query($query_maklumatkuarter, $supsrwk_epenyenggaraan) or die(mysql_error());
$row_maklumatkuarter = mysql_fetch_assoc($maklumatkuarter);
$totalRows_maklumatkuarter = mysql_num_rows($maklumatkuarter);$colname_maklumatkuarter = "-1";
if (isset($_SESSION['No_KP']))`{`
$colname_maklumatkuarter = $_SESSION['No_KP'];
}
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$query_maklumatkuarter = sprintf("SELECT * FROM `maklumatkuarter` WHERE No_KP = %s", GetSQLValueString($colname_maklumatkuarter, "text"));
$maklumatkuarter = mysql_query($query_maklumatkuarter, $supsrwk_epenyenggaraan) or die(mysql_error());
$row_maklumatkuarter = mysql_fetch_assoc($maklumatkuarter);
$totalRows_maklumatkuarter = mysql_num_rows($maklumatkuarter);
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['No_KP'])) {
$loginUsername=$_POST['No_KP'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/supsrwk_epenyenggaraan/aduan.php";
$MM_redirectLoginFailed = "/supsrwk_epenyenggaraan/index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$LoginRS__query=sprintf("SELECT No_KP, FROM maklumatkuarter WHERE No_KP=%s",
GetSQLValueString($loginUsername, "text"));
$LoginRS = mysql_query($LoginRS__query, $supsrwk_epenyenggaraan) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SELAMAT DATANG KE SISTEM e-Penyenggaraan</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<div align="center">
<input name="No_KP" type="text" class="txtbox" placeholder="NO KAD PENGENALAN" required>
<div align="center">
<button class="loginbtn">LOG MASUK</button>
<button class="loginbtn" type="reset">SEMULA</button></div>
</body>
</html>
我的index.php页面上出现的错误是你的SQL语法错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的'FROM maklumatkuarter WHERE No_KP ='960925135408'附近使用正确的语法。
我希望有人可以帮我解决这个问题。我只是编码的初学者。非常感谢
答案 0 :(得分:1)
"SELECT No_KP, FROM maklumatkuarter WHERE No_KP=%s
我猜错误在','尝试删除它。这是第三个查询
这样做:
"SELECT No_KP FROM maklumatkuarter WHERE No_KP=%s