php 用户登陆身份验证代码...
时间:2010-08-13 来源:linwins
<form action=111cnNet.php >
<input type=text name=username>
<input type=text name=password>
<input type=submit name=password value='提交'>
</form>
<?php
$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 where uid='$uname'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row=mysql_fetch_array($result)){
if($pwd==$row['password'])
{
header("location:http://www.111cn.Net");
}
else
echo 'error!';}
// 释放结果集
mysql_free_result($result);
// 关闭连接
mysql_close($link);
?>