In the ubutu 16.04 environment, the PHP and mysql databases, web page logon verification examples, ubutu16.04

Source: Internet
Author: User

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.

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.