<?
/*************************************** ***************
File name: login. php3
Login Check
Code: PHP 4
By Kevin Lee <webwing@21cn.com>
Database: MySQL.
Host: localhost Database: mydb
Table structure for table 'user'
--------------------------------------------------------
Create table user (
Id smallint (6) not null auto_increment,
User varchar (12) not null,
Passwd varchar (12) not null,
Name varchar (20 ),
Email varchar (30 ),
Level char (1 ),
Status char (1 ),
UNIQUE id (id)
);
--------------------------------------------------------
**************************************** ***************/
?>
<Script language = "javascript">
Function back (){
History. back ();
}
Function winclose (){
SetTimeout ("self. close ()", 10000 );
}
</Script>
<?
$ Db_id = mysql_pconnect ("localhost", "root ","");
$ SQL = "select id, user, passwd from user where user = '". $ name. "' and passwd = '". $ pwd ."'";
$ Result = mysql_db_query ("mydb", $ SQL );
$ Row = mysql_fetch_array ($ result );
$ Id = $ row [id];
If ($ id! = ""){
Session_start ();
Session_register ("yn ");
$ Yn = "yes ";
Echo "Echo "you have successfully logged on... "." <P> ";
Echo "<center>". "The window is automatically closed 10 seconds later." </center> ";
Echo "</body> }
Else {
Echo "incorrect account or password !!! ";
Echo "<P> ";
Echo "<center> ";
Echo "<a href = \" # \ "onclick = \" javascript: back () \ "> back </a> ";
Echo "</center> ";
}
?>
<! --
File name: login.htm
-->
<Html>
<Head>
<Title> system logon </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Style type = "text/css">
<! --
. Css1 {font-size: 10pt; color: # FFCC66}
-->
</Style>
</Head>
<Body bgcolor = "# ffffff" topmargin = 0 leftmargin = 0>
<Form method = "post" action = "login. php3">
<Table width = "210" bgcolor = "# ffffff" height = "106" bordercolor = "navajowhite" border = "1" style = "WIDTH: 210px">
<Tr bgcolor = "# 0000ff">
<Td colspan = "4">
<Div align = "center"> <B> <font color = "# ffffff" face = "_ GB2312"> system logon </font> </B> </div>
</Td>
</Tr>
<Tr bgcolor = "# f9fde1" bordercolor = "# cccccc">
<Td width = "71" class = "css1">
<Div align = "center"> User Account </div>
</Td>
<Td colspan = "3" align = middle>
<Input name = "name" size = "14">
</Td>
</Tr>
<Tr bgcolor = "# f9fde1" bordercolor = "# cccccc">
<Td width = "71" class = "css1">
<Div align = "center"> User Password </div>
</Td>
<Td colspan = "3" align = middle>
<Input type = "password" name = "pwd" size = "14">
</Td>
</Tr>
<Tr bgcolor = "# f9fde1" bordercolor = "# cccccc">
<Td colspan = "4" height = "26" style = "HEIGHT: 26px">
<Div align = "center">
<Input type = "submit" name = "Submit1" value = "" height = "20" style = "FONT-SIZE: smaller; HEIGHT: 22px">
</Div>
</Td>
</Tr>
</Table>
</Form>
</Body>
</Html>
<?
/************************
File name: login_chk.php3
************************/
If ($ yn! = "Yes "){
Echo "<script language = \" javascript \ "> \ n ";
Echo "<! -- \ N ";
Echo "history. back (); \ n ";
Echo "window. open ('.. /login/login.htm', 'login', 'height = 116, width = 210, top = 120, left = 200, toolbar = no, menubar = no, scrobllbar = no, resizable = no, location = no, status = no') \ n ";
Echo "--> \ n ";
Echo "</script> \ n ";
Exit;
}
?>
Example:
<? Require ("login_chk.php3");?>
<! -- File name: sample. php3 -->
<Html>
<Head> <Body>
Success! You have pass the checking.
</Body>
<Html>