一、login.phpphp
<?php
function yzm(){
$str="";
for($i=1;$i<=4;$i++){
$str.=rand(0,9);
}
return $str;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form method="post" action="msg.php">
<table>
<tr>
<td>用戶名:</td>
<td><INPUT TYPE="text" NAME="username"></td>
</tr>
<tr>
<td>密碼:</td>
<td><INPUT TYPE="text" NAME="password"></td>
</tr>
<tr>
<td>驗證碼:</td>
<td><INPUT TYPE="text" NAME=""size=4><INPUT TYPE="button" value='<?php echo yzm();?>'></td>
</tr>
<tr>
<td></td>
<td><INPUT TYPE="submit" name="submit" value="登陸"><INPUT TYPE="reset"></td>
</tr>
</table>
</form>
</body>
</html>html
二、msg.phpide
<?php
if(!empty($_POST['submit'])){
$name=$_POST['username'];
$pwd=$_POST['password'];
echo "用戶",$name,",你好";
}else{
header("Location:login.php");
}
?>
post