1、login.php
<?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>
2、msg.php
<?php
if(!empty($_POST[‘submit‘])){
$name=$_POST[‘username‘];
$pwd=$_POST[‘password‘];
echo "用户",$name,",你好";
}else{
header("Location:login.php");
}
?>
本文出自 “学而不思则罔” 博客,请务必保留此出处http://dyzyxy.blog.51cto.com/944775/1643741
原文地址:http://dyzyxy.blog.51cto.com/944775/1643741