嗨,我刚刚进入从数据库中vaild用户名和密码的时候,但是当我输入一个无效的用户名和密码,它只是循环使用PHP和MySQL的登录系统的工作创建一个登录系统回到即使我已经statment登录页面说它失败,如果登录这里失败,我想打印的是我的代码文件PHP登录系统不会响应错误陈述
<?php
require_once("Connections/connection.php");
error_reporting(E_ALL^E_NOTICE);
$userid = $_POST['userid'];
$password = $_POST['password'];
$submitted = $_POST['submitted'];
if ($userid && $password){
$query =sprintf("SELECT * FROM users where user_name= '$userid' and user_password = '$password'");
$result [email protected]_query($query);
$rowAccount [email protected]_fetch_array($result);
}
if ($rowAccount){
echo "The record exists so you can enter ";
} elseif($submitted){
print "you don't exist in the system!";
}
?>
我的HTML:
<!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>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="800">
<tr>
<th width="233" scope="col">User ID </th>
<th width="555" scope="col"><p>
<label for="userid"></label>
<label for="userid"></label>
<input type="text" name="userid" id="userid" />
</p>
<p> </p></th>
</tr>
<tr>
<td>Password </td>
<td> <label for="userid"></label> <label for="password"></label>
<input type="text" name="password" id="password" /> </td>
</tr>
<tr>
<td> </td>
<td> <input type="hidden" name="submitted" id="submitted" /> <input type="submit" name="Submit" id="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
得到回音工作的人必须给隐藏字段添加一个值,它的工作原理是
你'elseif'语句只检查的'$彦博值[“提交”]',而不是是否有任何记录... – BenM 2013-04-08 17:44:37
贵隐场“提交”保存任何形式的价值? – 2013-04-08 17:44:40
HTML和PHP代码都在同一个文件中?如果是,那么消息可能正在打印,但您只能使用浏览器的查看源选项来查看。尝试在消息之后使用die()... – 2013-04-08 17:45:11