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>