Introduction to PHP-User Registration Instance program full version

Source: Internet
Author: User

Create a Database Tutorial connection
MySQL tutorial _connect (' localhost ', ' 111cn.net ', ' www.111cn.net ');
mysql_select_db (' www.111cn.net ');//Database selection
mysql_query (' Set names "GBK");

Progress Query Operations
?>

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<script language= "JavaScript Tutorial" >
Check111cnnet ()
{

if (Myfm.uid.value = = ")
{
Alert (' Www.111cn.net prompts you: username error ');
return false;
}
if (! myfm.pwd.value!= ' && myfm.pwd.value = = myfm.pwd1.value)
{

Alert (' Www.111cn.net prompts you: two times password incorrect ');
return false;
}

}
</script>

<body>
<form id= "myFM" name= "myFM" method= "POST" action= ""
  <label>
  username br>   <input type= "text" name= "UID"/>
  <br>
  Password
  <input type= "text" Nam E= "pwd"/>
  <br>
  Password 2
  <input type= "text" name= "Pwd2"/>
<br>
& nbsp </label>
  <LABEL>
  <input type= "Submit" name= "submit" value= "register" onclick= "return Check111cnnet (); "/>
  </label>
</form>
</body>

<?php


if ($_post)
{
  $uid = $_post[' uid '];
  $pwd = $_post[' pwd '];
  $PWD 1 = $_post[' pwd1 '] ;
 if (Empty ($uid)) {exit ();} &NBSP
  $sql = "SELECT * from user where uid = ' $uid ' limit 0,10";
  $query = mysql_query ($sql) or Die ("W Ww.111cn.net prompts you: "Query Error");
 
 if (mysql_num_rows ($query))
 {
  echo ' user has already been registered ';
 }
 els E&NBSP;&NBSP
 {
  if (mysql_query ("INSERT into User (UID,PWD) VALUES (' $uid ', ' MD5 ($PWD) ')")
  {
   echo ' www.111cn.net prompts you: Register for success ';
  
  else
  {
   echo ' registration failed ';
  }
 
}

/*
Data table structure
CREATE TABLE ' 111cnNet '. ' User ' (
' ID ' INT (8) not NULL auto_increment,
' UID ' CHAR ($) NULL,
' pwd ' char (NULL),
PRIMARY KEY (' id ')
) ENGINE
This tutorial is only for learning to use no security processing, such as for commercial use of any problems with the site www.111cn.net has nothing to do
*/


Original site reprint must indicate the source or the source of responsibility http://www.111cn.net/phper/php.html
?>

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.