In the ubutu 16.04 environment, the PHP and mysql databases, web page logon verification examples, ubutu16.04
Just as the recent Domain Name Record Filing passed, the rise suddenly wanted to create a web page, although previously filed domain names also have this purpose.
I have asked a few people that it is very easy to build a website using PHP in linux,Here, we will focus on the logon verification;
The Prime Minister prepares several files, including index. php, conn. php, data. php, and login. php;
Login. php is mainly the data comparison part during the login process. The include ('conn. php') content is described below.
<?phpif(!isset($_POST['submit'])){ exit('login in error.');}$username = htmlspecialchars($_POST['username']);$password = MD5($_POST['password']);include('conn.php');echo"$password";$check_query = mysqli_query($result,"select USERID from USERINFO where EMAIL='$username' and PASSWORD='$password' limit 1");if($ret = mysqli_fetch_array($check_query)){ echo'connect true.';}else{ echo'connect false';}?>
Note that $ _ POST is for the content in method = "post" in form.
Because the MD5 encryption method is used in it, we also need to use the MD5 encryption method to update data in the background database encryption. The specific method is as follows:
UPDATE USERINFO SET PASSWORD = md5('root') WHERE USERID = 1000;
The tables and specific query locations are determined by the personal database.
Conn. php is mainly related to mysql database connections. It can be divided into database connections and database selection. (note that the return value of the database connection is optional. It is useful for reference later .)
<?phptry{$result = mysqli_connect('localhost','root','root');mysqli_select_db($result,'WEBDATAS');}catch(Exception $e){ echo $e->message; exit;}if(!$result){ return false;}echo "ok\n";?>
The rest is mainly index. php: this file is related to the home page. I will only describe the login-related part (here, the template in boostrap is used. If you are interested, refer to Baidu boostrap)
<?phpsession_start();include_once('data.php');$handle = db_connect();if(!$handle){ echo 'Did not access to the database';}else{ echo'connect success';}?>
The data. php logon part is as follows:
<Div class = "modal fade" tabindex = "-1" role = "dialog" id = "login"> <div class = "modal-dialog" role = "document"> <div class = "modal-content"> <div class = "modal-header"> <button type = "button" class = "close" data-dismiss = "modal" aria -label = "Close"> <span aria-hidden = "true"> × </span> </button>
This is basically the login verification part. It is mainly compared with the database data. The initial symmetric encryption method has not been carefully studied, I will have the opportunity to take a closer look later.
In the above ubutu 16.04 environment, the PHP and mysql databases, Web login verification examples are all the content that I have shared with you, and I hope you can give a reference, we also hope that you can support the customer's home.