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;
Name |
ISBN |
Store |
Do |
<?php do { ?>
<?php echo $row_rsbooks['Name']; ?> |
<?php echo $row_rsbooks['ISBN']; ?> |
<?php echo $row_rsbooks['Store']; ?> |
rent |
<?php } while ($row_rsbooks = $rsbooks->fetch_assoc()); ?>
<?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 ,...