What code does form php MySQL implement authentication?

Source: Internet
Author: User

The following articles mainly use the actual application code to introduce the actual authentication operations of form php MySQL. We often use form php MySQL in actual operations, the following articles describe how to perform identity authentication.

 
 
  1. <?php 
  2. $uname=$_POST["username"];  
  3. $pwd=$_POST["password"];  
  4. $link = MySQL_connect('localhost', 'root', '123456')  
  5. or die('Could not connect: ' . MySQL_error());  
  6. MySQL_select_db('ruida') or die('Could not select database'); 

Execute SQL query

 
 
  1. $query = 'SELECT * FROM user';  
  2. $result = MySQL_query($query) or die('Query failed: ' . MySQL_error());  
  3. while($row=MySQL_fetch_array($result)){  
  4. if($uname==$row['username'] && $pwd==$row['password'])  

Page Jump

 
 
  1. }  
  2. else  
  3. echo 'error!';} 

Release result set

 
 
  1. MySQL_free_result($result); 

Close connection

 
 
  1. MySQL_close($link);  
  2. ?>  

The above content describes how to implement authentication for form php MySQL.

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.