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