PHP + MySQL login code registration

Source: Internet
Author: User
Tags mysql tutorial php tutorial mysql login
The code is as follows: Copy code

<? Php Tutorial
$ DB_HOST = "localhost"; // database tutorial host location
$ DB_LOGIN = "root"; // account used by the database
$ DB_PASSWORD = "admin"; // database password
$ DB_NAME = "flag"; // database name

$ Conn = mysql tutorial _ connect ($ DB_HOST, $ DB_LOGIN, $ DB_PASSWORD );
Mysql_select_db ($ DB_NAME );
?>


************************* 222222

<? Php
Functiondb_query ($ sqlstr) {returnmysql_query ($ sqlstr );}
Functiondb_num_rows ($ res) {returnmysql_num_rows ($ res );}
Functiondb_fetch_array ($ res) {returnmysql_fetch_array ($ res );}
Functiondb_fetch_object ($ res) {returnmysql_fetch_object ($ res );}
Functiondb_data_seek ($ res, $ num) {return mysql_data_seek ($ res, $ num );}
Functiondb_insert_id ($ res) {returnmysql_insert_id ($ res );}
?>


 

*************************** 333333333333

<?
Include ("registry_up.htm") // import the upper half of the webpage
?>
<Script>
Functioncheck ()
{
If (document. regstep1.username. value = "")
{
Alert ("account not entered ");
Returnfalse;
}
If (document. regstep1.userpass. value = "")
{
Alert ("Do not use blank passwords ");
Returnfalse;
}
If (document. regstep1.userpass. value! = Document. regstep1.userpass2. value)
{
Alert ("The two passwords are different ");
Returnfalse;
}

Document. regstep1.submit ();

}
</Script>

<Script>
<! --------- Function BEGIN ---------->
Function Checkname (){
Var Name = document. regstep1.username. value;
Window. open ("uniquecheck. php? Name = "+ Name," Check "," width = 300, height = 10, status = 0, scrollbars = 0, resizable = 1, menubar = 0, toolbar = 0, location = 0 ");
}
<! ---------- Function END ----------->
</Script>

<Form name = "regstep1" method = "post" action = "registry_do.php">
<? Php/*?> <Inputtype = "submit" name = "username" value = "<? = $ Username?> ">
<Inputtype = "submit" name = "userpass" value = "<? = $ Userpass?> ">
<Inputtype = "submit" name = "pass_rem" value = "<? = $ Pass_rem?> ">
<Inputtype = "submit" name = "pass_ans" value = "<? = $ Pass_ans?> ">
<? Php */?>

<BR>
<Table width = "446" border = "0" bordercolor = "#000000" align = "center" cellspacing = "0">
<Tr>
<Td>
<Table width = "440" border = "0" height = "220" align = "center" bgcolor = "# EEEEEE" cellspacing = "0" cellpadding = "0">
<Tr>
<Td colspan = "2" bgcolor = "# FFFFFF">
<Divalign = "center"> </div>
</Td>
</Tr>
<Tr>
<Td>
<Div align = "center"> Account No. </div>
</Td>
<Td height = "18">
<Divalign = "center">
<Input type = "text" name = "username" size = "15">
<InputonClick = "webpage effect: Checkname ()" type = button value = "Check account" name = "button">
</Div>
</Td>
</Tr>

<Tr>
<Td bgcolor = "# FFFFFF">
<Divalign = "center"> password </div>
</Td>
<Td height = "6" bgcolor = "# FFFFFF">
<Div align = "center">
<Inputtype = "password" name = "userpass" size = "20">
</Div>
</Td>
</Tr>
<Tr>
<Td>
<Divalign = "center"> confirm the password </div>
</Td>
<Td height = "2">
<Divalign = "center">
<Inputtype = "password" name = "userpass2" size = "20">
</Div>
</Td>
</Tr>
<Tr>
<Td bgcolor = "# FFFFFF">
<Divalign = "center"> Password Display </div>
</Td>
<Td height = "2" bgcolor = "# FFFFFF">
<Divalign = "center">
<Selectname = "pass_rem">
<Optionvalue = "0"> your pet name </option>
<Optionvalue = "1"> country you want to visit </option>
<Optionvalue = "2"> your favorite sports </option>
<Optionvalue = "3"> foods you hate most </option>
<Optionvalue = "4"> What do you do most often at home </option>
<Optionvalue = "5"> your favorite movies </option>
</Select>
</Div>
</Td>
</Tr>
<Tr>
<Td>
<Divalign = "center"> answer </div>
</Td>
<Td height = "2">
<Divalign = "center">
<Input type = "text" name = "pass_ans" size = "20">
</Div>
</Td>
</Tr>
<Tr>
<Td colspan = "2" bgcolor = "# FFFFFF">
<Divalign = "center">
<Inputtype = "reset" name = "reset" value = "clear and refill">
<Inputtype = "button" name = "Submit" value = "Submit" onClick = "check ();">
</Div>
</Td>
</Tr>
</Table>
</Td>
</Tr>
</Table>
</Form>

<?
Include ("registry_down.htm") // import the lower part of the webpage
?>

****************************** 44444444444

<?
Include ("db_conn.php ");
Include ("db_func.php ");

// Add a member account/password BEGIN
$ SQLStrUser = "insert into member (m_username, m_userpass, m_pass_rem, m_pass_ans )";
$ SQLStrUser. = "VALUES ('$ username',' $ userpass', '$ pass_rem', '$ pass_ans ')";
Db_query ($ SQLStrUser );
// Add the member account and password END


?>

<Script>
Alert ("<? Php echo "registration completed";?> ");
Location. href = "www.111cn.net ";
</Script>

 

**************************** 55555555555555555


<?
Include ("db_conn.php ");
Include ("db_func.php ");

// Query whether the registered account name contains the indecent word BEGIN
$ SQLStr = "SELECT * FROM nogood WHERE n_name LIKE '% $ username % '";
$ Res = db_query ($ SQLStr );
// Query whether the registered account name contains an indecent word "END"

If (db_num_rows ($ res)> 0) // if the queried data is consistent
{
Echo "<script> ";
Echo "alert (" Do not use indecent names ". $ username." account ");";
Echo "location. href =" registry1.php ";";
Echo "</script> ";
}
?>

 

* ***************************** 6 ^


<?
Include ("db_conn.php ");
Include ("db_func.php ");

// Query whether the database has the user name BEGIN
$ Sqlstr = "SELECT * FROM member WHERE m_username = '$ name '";
$ Res = db_query ($ sqlstr );
// Query whether the database has the user name BEGIN

If (db_num_rows ($ res)> 0) // check whether the query result has data
Echo "<br> <center> this account name". $ name. "registered and used </center> ";
Else
Echo "<br> <center> this account name". $ name. "not registered yet </center> ";
?>

 

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.