这是一个简单的登入系统,
然后要过滤特殊字符避免资料隐码攻击
我是用mysql_real_escape_string函数
想请问大家如果要写
如果帐号密码栏有特殊字符就跳出警告视窗该怎么写呢
<?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['textfield2'])) {
$loginUsername=mysql_real_escape_string($_POST['textfield2']);
$password=mysql_real_escape_string($_POST['textfield']);
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "loginOK.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_kenny, $kenny);
$LoginRS__query=sprintf("SELECT ID, password FROM users WHERE ID='".$loginUs
ername."' AND password='".$password."'",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "tex
t"));
$LoginRS = mysql_query($LoginRS__query, $kenny) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//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 );
}
}
?>