php+mysql实现身份验证代码_PHP教程
时间:2021-07-01 10:21:17
帮助过:27人阅读
代码如下:
$uname=$_POST["username"];
$pwd=$_POST["password"];
$link = mysql_connect('localhost', 'root', '123456')
or die('Could not connect: ' . mysql_error());
mysql_select_db('ruida') or die('Could not select database');
// 执行 SQL 查询
$query = 'SELECT * FROM user';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row=mysql_fetch_array($result)){
if($uname==$row['username'] && $pwd==$row['password'])
{
//页面跳转
}
else
echo 'error!';}
// 释放结果集
mysql_free_result($result);
// 关闭连接
mysql_close($link);
?>
http://www.bkjia.com/PHPjc/321444.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321444.htmlTechArticle 代码如下:?php $uname=$_POST["username"]; $pwd=$_POST["password"]; $link = mysql_connect('localhost', 'root', '123456') or die('Could not connect: ' . mysql_error(...