无聊写个登陆小测验,有表单和数据库简单操作
原来PHP这样简单.忘写环境了win2003,php5.2.0,mysql5.0.27.apache2.2.3
mysql数据库user,表temp,字段uid,pwd.//注:用户名,密码:)
<html>
<head>
<title>登陆小测验</title>
</head>
<body>
<?php
//echo $_POST['uid'];
if($_POST['uid']==null and $_POST['pwd']==null){
echo '还没登陆啊!';
}
else{
//接收变量并输出
$username=$_POST['uid'];
$password=$_POST['pwd'];
//echo $username.$password;测试变量传递
//建立连接
$conn=mysql_connect("localhost","root");
//打开数据库
mysql_selectdb(user,$conn);
//获取结果集
$query="select * from temp where uid='$username' and pwd='$password'";
$result=mysql_query("$query");
if($myrow = mysql_fetch_array($result))
{
echo "欢迎您,$username!";
}
else
{
echo "用户名或密码错";
}
}
?>
<form actions="login.php" method="post">
姓名:<input type="text" name="uid" /><br/>密码:<input type="password" name="pwd"/><br/><input type="submit" value="yes" />
</form>
</body>
</html>
[此贴子已经被作者于2007-7-7 16:22:34编辑过]