PHPMYSQL implements login and fuzzy query functions. mysql fuzzy query _ PHP Tutorial

Source: Internet
Author: User
Tags learn php programming php session php mysql mysql login
PHPMYSQL implements login and fuzzy query, and mysql fuzzy query. PHPMYSQL implements login and fuzzy query functions. mysql fuzzy query uses the following software versions: PHP version 5.5.12 and MYSQL version 5.6.17; apache2.4.9 wampserver I. PHP MYSQL implement login and fuzzy query functions. mysql fuzzy query

The software version used in this article is as follows: PHP version 5.5.12; MYSQL version 5.6.17; wampserver for Apache 2.4.9
I. PHPMYSQL login
There are two files in total:Login. phpAndLogincheck. php;
Form code:


Background processing code:

<? Php if (isset ($ _ POST ["submit"]) & $ _ POST ["submit"] = "login ") {$ user = $ _ POST ["username"]; $ psw = $ _ POST ["password"]; if ($ user = "" | $ psw = "") {echo "script alert ('Enter your username or password! '); History. go (-1); script ";} else {$ link = mysqli_connect ('localhost', 'sa ', '123', 'account '); // link to the database mysqli_select_db ($ link, "account"); mysqli_query ($ link, 'setname utf8 '); $ SQL = "selectuser from zhanghu where user = '$ _ POST [username]'"; $ result = mysqli_query ($ link, $ SQL) or die ("Failed ". mysql_error (); if ($ num = mysqli_num_rows ($ result) {$ row = mysqli_fetch_array ($ result); // store data in the array as an index echo" Welcome "; echo $ row [0];} else {echo" script alert ('The user name or password is incorrect! '); History. go (-1); script ";}}} else {echo" script alert ('submit Failed! '); History. go (-1); script ";}?>

Account database content:

II. implement fuzzy query in PHPMYSQL

Query the database (only for PHP code ):

<?php     $mysqli=newmysqli();                  $mysqli->connect("localhost","sa", "123456");     if(mysqli_connect_errno()) {          printf("Failllllll:%s\n", mysqli_connect_error());          exit();     }     $mysqli->select_db("booklib");       $mysqli->query("SETNAMES utf8");        $rsbooks= $mysqli->query("select * from books where Name like'%$_POST[bookname]%'");  $row_rsbooks = $rsbooks->fetch_assoc();  $totalRows_rsbooks = $rsbooks->num_rows;    ?> Totel<?php echo $totalRows_rsbooks ?>books;
 
  <?php do { ?> 
    <?php } while ($row_rsbooks = $rsbooks->fetch_assoc()); ?> 
  
Name ISBN Store Do
<?php echo $row_rsbooks['Name']; ?> <?php echo $row_rsbooks['ISBN']; ?> <?php echo $row_rsbooks['Store']; ?> rent
<?php $rsbooks->close(); $mysqli->close();?>

The database table content is as follows:

Query:

Result:

The above is all the content of this article. I hope it will help you learn php programming.

Articles you may be interested in:
  • Two steps to enable the remote login account of the MySQL database
  • How to implement multi-keyword fuzzy query in a single MySQL table
  • PHP + MYSQL implementation code for permission judgment upon login of the member system
  • A simple web page password to log on to php code
  • New mysql users cannot log on.
  • MySql like fuzzy query wildcard usage
  • PHP jump to the pre-login page after login implementation ideas and code
  • Php session logout and login problems
  • Introduction to four usage of fuzzy query in mysql
  • Thinkphp implements like fuzzy search instances

Http://www.bkjia.com/PHPjc/1099081.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1099081.htmlTechArticlePHP MYSQL login and fuzzy query to achieve two major functions, mysql fuzzy query the software version used in this paper is as follows: PHP version 5.5.12; MYSQL version 5.6.17; Apache 2.4.9 wampserver I ,...

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.