A mysql-based login verification program

Source: Internet
Author: User

<?
/*************************************** ***************
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>


Related Article

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.