PHP writes data to MySQL

Source: Internet
Author: User

Use the Post method of PHP to write the acquired data to the MySQL database.

First, create a form page to receive user data denglu.html 

<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>
<form action= "./xinxi.php" method= ' POST ' >
<p> Username: <input type= "text" name= "username" value= "Please enter mobile phone number" ></p>
<p> Sex: <input type= "Radio" name= "Sex" value= "man" > Mr. <input type= "Radio" name= ' Sex ' value= "woman" > Lady </p>
<p> Date of birth: <input type= "text" name= "Year" value= "1990" > Years <input type= "text" Name= "Yue" value= "Down" > Month <input type= "text" Name= "ri" value= "> Day </p>
<p> Email: <input type= "text" name= "email" ></p>
<p> Password: <input type= "password" name= "password" ></p>
<p> Confirm Password: <input type= "password" name= "password" ></p>
<p><input type= "Submit" value= "Login" ></p>
</form>

Then create a login.php to load the denglu.html

<?php

Include './denglu.html ';

Create a xinxi.php that can receive data from a user and can use a statement to manipulate MySQL, which is the server that is used to manipulate the form data specified in denglu.html.

1<?PHP4 $birth=$_post[' Year '].$_post[' Yue '].$_post[' Ri ']; 5 $pass=MD5($_post[' Password ']); 6 7 $flag=mysql_connect(' localhost ', ' root ', ' ****** '); 8 $f=mysql_query(' Use test1 '); 9 $f=mysql_query(' Set names UTF8 ');
       Ten $conn= "INSERT into Yonghu (Username,sex,birth,email,password) VALUES (' {$_post[' username ']} ', ' {$_post[' Sex ']} ', ' {$birth}‘,‘{$_post[' Email ']} ', ' {$pass}‘);"; One if($_post){ A $username=isset($_post[' username ']) ?$_post[' username ']: '; - if(isset($username)){ - mysql_query($conn); the Echo"INSERT into Yonghu (Username,sex,birth,email,password) VALUES (' {$_post[' username ']} ', ' {$_post[' Sex ']} ', ' {$birth}‘,‘{$_post[' Email ']} ', ' {$pass}‘);"; - Echo"; - die; + } A}

Effect

PHP writes data to MySQL

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.