我用php做了一个登录页面。当我使用用户名和密码作为数字时,没有问题。但如果我使用字母作为用户名和密码,则会导致问题,并出现以下错误:
“Where 子句”中的未知列“列名”
任何帮助将不胜感激
更新 :
我使用dreamweaver,并通过以下步骤制作登录页面:
插入->数据对象->用户验证->登录用户
更新 2:
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['user'])) {
$loginUsername=$_POST['user'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "ok.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_cn3, $cn3);
$LoginRS__query=sprintf("SELECT * FROM users WHERE `user`=%s AND pass=%s",
GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $cn3) 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();}
//declare two session variables and assign them
$_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 );
}
}
?>