How PHP detects password length

Source: Internet
Author: User

An example

1, index.php



<metahttp-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> detect the length of the string </title>
<styletype= "Text/css" >
<!--
. style1 {font-size:12px}
. style2 {
Font-family: "XXFarEastFont-Imitation";
font-size:14px;
}
Body {
margin-left:00px;
margin-top:0px;
margin-right:0px;
margin-bottom:0px;
}
. STYLE3 {color: #FF0000}
-->
</style>


<body>
<tablewidth= "392" height= "257" border= "0" cellpadding= "0" cellspacing= "0" >
<tr>
<tdalign= "left" valign= "top" ><tablewidth= "392" border= "0" cellpadding= "0"
cellspacing= "0" >
<tr>
<tdwidth= "height=" "113" >&nbsp;</td>
<tdwidth= ">&nbsp;</td>"
<tdwidth= "119" >&nbsp;</td>
<tdwidth= "a" >&nbsp;</td>
<tdwidth= "align=" "Center" class= "Style1" >&nbsp;</td>
</tr>
<formname= "Form1" method= "Post" action= "index_ok.php" >
<tr>
<tdheight= "></td>"
<tdalign= "center" ><spanclass= "Style1" > Username </span>:</td>
<td><inputname= "User" type= "text" id= "user" size= "></td>"
<tdalign= "center" ><inputname= "ImageField" type= "image"
Src= "Images/btn_dl.jpg" width= "height=" border= "0" ></td>
<td>&nbsp;</td>
</tr>
<tr>
<tdheight= ">&nbsp;</td>"
<tdalign= "center" ><spanclass= "Style1" > Password </span>:</td>
<td><inputname= "pwd" type= "password" id= "pass" size= "></td>"
<tdcolspan= "2" align= "left" ><spanclass= "STYLE3" >*&nbsp; password length cannot be less than 6 digits
</span></td>
</tr>
</form>
<tr>
<tdheight= ">&nbsp;</td>"
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</body>

2, index_ok.php

  
if (strlen ($_post["pwd"]) <6) {//Detect user password length less than 6
echo "<script>alert (' user password must not be less than 6 bits in length!"); History.back ();</script> ";
}
else{
echo "User information input Legal! ";
}
?>

Two running results

int strlen (String $string)

Returns the length of a given string of strings.

Parameters

String

A string that needs to be computed for length.

return value

Success returns the length of string strings, or 0 if the string is empty.

Source: http://cakin24.iteye.com/blog/2348826

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.