1. index.php
<form method="post" action="dbtest.php">
姓名:
<input type="text" name="name">
<br>
<br>
密码:
<input type="text" name="pwd">
<input type="submit" name="submit" value="提交">
</form>
2.php dbtest.php
<?php
$name = $_POST["name"];
$pwd = $_POST["pwd"];
$con = mysql_connect("localhost","root","123456");
mysql_select_db("test", $con);
$result = mysql_query("SELECT password FROM usertest where username=‘$name‘ ");
if($row = mysql_fetch_array($result)){
if($row[‘password‘] == $pwd){
header("location: page2.php");
}else{
echo "密码错误";
}
}else{
echo "用户不存在";
}
mysql_close($con);
?>
3.跳转页 page2.php
<?php
phpinfo();
?>