Use PHP to connect to the database to operate the user registration, review and login page, php user registration

Source: Internet
Author: User

Use PHP to connect to the database to operate the user registration, review and login page, php user registration

Registration page

<Body>
<H1> registration page <Form action = "zhucechuli. php" method = "post">
<Div> User name: <input type = "text" name = "uid"/> </div>
<Div> password: <input type = "text" name = "pwd"/> </div>
<Div> name: <input type = "text" name = "name"/> </div>
<Div> Gender: <input type = "text" name = "sex"> </div>
<Div> birthday: <input type = "text" name = "birthday"> </div>
<Input type = "submit" value = "register"/>
</Form>
</Body>

Registration processing page

<? Php
$ Uid = $ _ POST ["uid"];
$ Pwd = $ _ POST ["pwd"];
$ Name = $ _ POST ["name"];
$ Sex = $ _ POST ["sex"];
$ Birthday = $ _ POST ["birthday"];
 
Include ("LZY. class. php ");
$ Db = new LZY ();
$ SQL = "insert into zhuce VALUES ('{$ uid}', '{$ pwd}', '{$ name}', '{$ sex }', '{$ birthday}', 0 )";
 
If ($ db-> query ($ SQL, 0 ))
{
Header ("location: zhuceyemiandenglu. php ");
}
Else
{
Echo "registration failed! ";
}

Logon page

<Body>
<H1> page logon <Form action = "zcdlchuli. php" method = "post">
<Div> User name: <input type = "text" name = "uid"/> </div>
<Div> password: <input type = "password" name = "pwd"/> </div>
<Div> <input type = "submit" value = "Logon"/> </div>
</Form>
</Body>

Registration logon process page

<? Php
$ Uid = $ _ POST ["uid"];
$ Pwd = $ _ POST ["pwd"];
Include ("LZY. class. php ");
$ Db = new LZY ();
 
 
 
$ SQL = "select * from zhuce where uid = '{$ uid }'";
$ Arr = $ db-> Query ($ SQL );
 
If ($ arr [0] [1] ==$ pwd &&! Empty ($ pwd ))
{
If ($ arr [0] [5])
{
Header ("location: zcmain. php ");
}
Else
{
Echo "this user has not passed review! ";
}
}
Else
{
Echo "Logon Failed! ";
}

Registration page

<Body>
 
<H1> User review  
<Table width = "100%" border = "1" cellpadding = "0" cellspacing = "0">
 
<Tr>
<Td> User Name </td>
<Td> name </td>
<Td> gender </td>
<Td> birthday </td>
<Td> operation </td>
</Tr>
 
<? Php
Include ("LZY. class. php ");
$ Db = new LZY ();
 
$ SQL = "select * from zhuce ";
$ Arr = $ db-> Query ($ SQL );
 
Foreach ($ arr as $ v)
{
$ Str = $ v [5]? "<Span style = 'background-color: green'> passed </span>": "<a href = 'zctongguo. php? Uid = {$ v [0]} '> pass </a> ";
 
Echo "<tr>
<Td >{$ v [0]} </td>
<Td >{$ v [2]} </td>
<Td >{$ v [3]} </td>
<Td >{$ v [4]} </td>
<Td >{$ str }</td>
</Tr> ";
}
 
?>
 
</Table>
 
</Body>
</Html>

Approved code

<? Php
$ Uid = $ _ GET ["uid"];
Include ("LZY. class. php ");
$ Db = new LZY ();
 
$ SQL = "update zhuce set isok = 1 where uid = '{$ uid }'";
If ($ db-> Query ($ SQL, 0 ))
{
Header ("location: zcmain. php ");
}
Else
{
Echo "failed to pass! ";
}

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.