PHP full site permission verification code example:
- < Html>
- < Head> < Title>E
- </Title>
- </Head>
- < Body>
- < FormAction = "login. php"
Method = "POST">
User:
- < InputType = "text"
Name = "username">
- < Br>
Password:
- < InputType = "password"
Name = "password">
- < InputType = "Submit"
Value = "OK">
- < InputType = "reset"
Value = "cancel">
- </Form>
- </Body>
- </Html>
---------------- Conn. php --------------------------
- <? Php
- $ Host = '1970. 0.0.1 ';
- $ Mysql_user = 'root ';
- $ Mysql_password = 'qeephp ';
- $ Mydb = 'learn ';
- $ Link = mysql_connect ($ host,
$ Mysql_user, $ mysql_password)
- Or die ("unable to connect to the database :"
. Mysql_error ());
- Mysql_select_db ($ mydb );
- ?>
---------------------------- Login. php ------------------
- <?
- $ Username = $ _ POST ['username'];
- $ Password = $ _ POST ['Password'];
- If ($ username = ""){
- Echo "<script language = 'javascript '>
Alert ('invalid operation! '); Location. href =
'Index. php'; </script> ";
- Exit;
- }
- Require_once ("conn. php ");
- $ SQL = "SELECT * FROM admin where
Username = '$ username '";
- $ Result = mysql_query ($ SQL );
- $ Row = mysql_fetch_array ($ result );
- If ($ row ['username'] = ""){
- Echo "<script language = 'javascript '>
Alert ('user name is incorrect! '); Location. href =
'Index. php'; </script> ";
- Exit;
- } Else if ($ row ['Password']! = $ Password ){
- Echo "<script language = 'javascript '>
Alert ('wrong password! '); Location. href = 'index
. Php'; </script> ";
- Echo "Incorrect password ";
- Exit;
- } Else {
- Session_start ();
- $ _ SESSION ['user'] = $ username;
- Echo "<script language = 'javascript '>
Alert ('login successful! '); Location. href =
'List. php'; </script> ";
- }
- ?>
------------------ Check. php --------------------
- <?
- Session_start ();
- If (! Isset ($ _ SESSION ['user'])
- {
- Echo "<script language = 'javascript '>
Alert ('invalid operation! '); Location. href =
'Index. php'; </script> ";
- Exit;
- } Else {
- Echo "welcome". $ _ SESSION ['user']
. "Log on to the system ";
- }
- ?>
--------------------- List. php -----------------
- <?
- Include 'Check. php ';
- ?>
- <Html>
- <Head>
- <Script type = "text/javascript"
Src = "player/swfobject. js"> </script>
- </Head>
- <Body>
- <H3> single file playback:
- <P id = "player1"> <a href ="
Http://www.macromedia.com/go/
Getflashplayer "> get a player </a> watch a movie </p>
- <Script type = "text/javascript">
- Var s1 = new SWFObject ("player/
Flvplayer.swf "," single "," 300 "," 170 "," 7 ");
- S1.addParam ("allowfullscreen", "true ");
- S1.addVariable ("file", "player/ad. flv ");
- S1.addVariable ("image", "player/preview.jpg ");
- S1.addVariable ("width", "300 ");
- S1.addVariable ("height", "170 ");
- S1.write ("player1 ");
- </Script>
- <H3> playlist file, with different
Colors:
- <P id = "player2"> <a href = "http:
// Www.macromedia.com/go/getflashplayer ">
Get the Flash Player </a> to see this player. </p>
- <Script type = "text/javascript">
- Var s2 = new SWFObject ("player/flvplayer
. Swf "," playlist "," 300 "," 312 "," 7 ");
- S2.addParam ("allowfullscreen", "true ");
- S2.addVariable ("file", "player/playlist. xml ");
- S2.addVariable ("displayhigh", "200 ");
- S2.addVariable ("backcolor", "0x000000 ");
- S2.addVariable ("frontcolor", "0 xCCCCCC ");
- S2.addVariable ("lightcolor", "0x557722 ");
- S2.addVariable ("width", "300 ");
- S2.addVariable ("height", "312 ");
- S2.write ("player2 ");
- </Script>
- </Body>
- </Html>
------------------ Logout. php -------------------------
- <? Php
- Unset ($ _ SESSION ['user']);
- Unset ($ _ SESSION ['Password']);
- Echo "logout successful ";
- ?>
The above is the specific implementation of PHP full site permission verification.