A simple web page password to log on to php code

Source: Internet
Author: User

Copy codeThe Code is as follows:
<? Php
$ Password = "1234"; // here is the password
$ P = "";
If (isset ($ _ COOKIE ["isview"]) and $ _ COOKIE ["isview"] = $ password ){
$ Isview = true;
} Else {
If (isset ($ _ POST ["pwd"]) {
If ($ _ POST ["pwd"] = $ password ){
Setcookie ("isview", $ _ POST ["pwd"], time () + 3600*3 );
$ Isview = true;
} Else {
$ P = (empty ($ _ POST ["pwd"])? "The password is required for viewing. Enter the password. ":" The password is incorrect. Please enter it again. ";
}
} Else {
$ Isview = false;
$ P = "enter the password to view the password. Contact me for the password. ";
}
}
If ($ isview) {?>
Here is what is displayed after the password is successful
<? Php} else {?>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Meta http-equiv = "pragma" content = "no-cache"/>
<Meta http-equiv = "cache-control" content = "no-cache"/>
<Meta http-equiv = "expires" content = "0"/>
<Title> reminds you to enter your password. </title>
<! -- [If lt IE 6]>
<Style type = "text/css">
. Z3_ie_fix {
Float: left;
}
</Style>
<! [Endif] -->
<Style type = "text/css">
<! --
Body {
Background: none;
}
. Passport {
Border: 1px solid red;
Background-color: # FFFFCC;
Width: 400px;
Height: 100px;
Position: absolute;
Left: 49.9%;
Top: 49.9%;
Margin-left:-200px;
Margin-top:-55px;
Font-size: 14px;
Text-align: center;
Line-height: 30px;
Color: # 746A6A;
}
-->
</Style>
<Div class = "passport">
<Div style = "padding-top: 20px;">
<Form action = "? Yes "method =" post "style =" margin: 0px; "> enter your password.
<Input type = "password" name = "pwd"/> <input type = "submit" value = "View"/>
</Form>
<? Php echo $ p;?>
</Div>
</Div>
<? Php
}?>
</Body>
</Html>

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.