PHP登录菜单
代码
index.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>检测字符串的长度</title>
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style2 {
font-family: "华文仿宋";
font-size: 14px;
}
body {
margin-left: 00px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE3 {color: #FF0000}
-->
</style>
</head>
<body>
<table width="392" height="257" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" background="images/bg.jpg"><table width="392" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="48" height="113"> </td>
<td width="75"> </td>
<td width="119"> </td>
<td width="72"> </td>
<td width="78" align="center" class="style1"> </td>
</tr>
<form name="form1" method="post" action="index_ok.php">
<tr>
<td height="33"> </td>
<td align="center"><span class="style1">用户名</span>:</td>
<td><input name="user" type="text" id="user" size="15"></td>
<td align="center"><input name="imageField" type="image" src="images/btn_dl.jpg" width="50" height="20" border="0"></td>
<td> </td>
</tr>
<tr>
<td height="27"> </td>
<td align="center"><span class="style1">密码</span>:</td>
<td><input name="pwd" type="password" id="pass" size="15"></td>
<td colspan="2" align="left"><span class="STYLE3">* 密码长度不能少于6位</span></td>
</tr>
</form>
<tr>
<td height="31"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
index_ok.php
处理
<?php
if(strlen($_POST["pwd"])<6){ //检测用户密码的长度是否小于6
echo "<script>alert('用户密码的长度不得少于6位!请重新输入'); history.back();</script>";
}
else{
echo "用户信息输入合法!";
}
?>