Php/Mysql 登录认证 [英] Php/Mysql login authentication
本文介绍了Php/Mysql 登录认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用 Php/mysql 进行身份验证,请使用以下方法.我使用了一个表单来登录.请检查以下内容并帮助我?
I am unable to authenticate using Php/mysql, using the following method. I used a form in order to login. Please check the following and help me out?
表单.php
<html>
<body>
<h2>Authentication</h2>
<form action="login.php" method="post">
<label>Userid :</label>
<input type="text" id="userid" name="userid" >
<label>Password :</label>
<input type="password" id="password" name="password">
<input name="submit" type="submit" value=" Login ">
<span><?php echo $error; ?></span>
</form>
</body>
</html>
登录.php
<?php
$message="";
if(count($_POST)>0) {
mysql_connect("localhost", "root", "kami123")or
die(mysql_error());
mysql_select_db("ccmsdb") or die(mysql_error());
$result = mysql_query("SELECT *FROM client WHERE
userid='" . $_POST["userid"] . "' AND
password = '". $_POST["password"]."'");
$count = mysql_num_rows($result);
if($count==0) {
$message = "Invalid Username or Password!";
} else {
$message = "You are successfully authenticated!";
}
}
?>
推荐答案
除了评论中已经提到的内容之外,您在查询中还缺少一个空格:
Besides what's already mentioned in the comments, you are missing a space in the query:
SELECT *FROM client WHERE
应该
SELECT * FROM client WHERE
这篇关于Php/Mysql 登录认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文