In the ubutu 16.04 environment, PHP and mysql databases, and Web page logon verification ., Ubutu16.04

Source: Internet
Author: User

In the ubutu 16.04 environment, PHP and mysql databases, and Web page logon verification ., 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, saying that it is very easy to build a website using PHP in linux. Here I will mainly talk about the login 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.

 1    <?php 2 if(!isset($_POST['submit'])){ 3     exit('login in error.'); 4 } 5 $username = htmlspecialchars($_POST['username']); 6 $password = MD5($_POST['password']); 7 include('conn.php'); 8 echo"$password"; 9 $check_query = mysqli_query($result,"select USERID from USERINFO where EMAIL='$username' and PASSWORD='$password' limit 1");10 if($ret = mysqli_fetch_array($check_query)){11 12     echo'connect true.';13 }14 else15 {16     echo'connect false';17 }18 ?>

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 .)

 1 <?php 2 try{ 3 $result = mysqli_connect('localhost','root','root'); 4 mysqli_select_db($result,'WEBDATAS'); 5 }catch(Exception $e) 6 { 7     echo $e->message; 8     exit; 9 }10 if(!$result)11 {12     return false;13 }14 echo "ok\n";15 ?>

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:

1 <div class = "modal fade" tabindex = "-1" role = "dialog" id = "login"> 2 <div class = "modal-dialog" role = "document "> 3 <div class =" modal-content "> 4 <div class =" modal-header "> 5 <button type =" button "class =" close "data-dismiss = "modal" aria-label = "Close"> <span aria-hidden = "true"> & times; </span> </button> 6 

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.

 

Related Article

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.