Home > Backend Development > PHP Tutorial > Submit php form to database_PHP tutorial

Submit php form to database_PHP tutorial

WBOY
Release: 2016-07-13 10:26:56
Original
1247 people have browsed it

1. PHP configuration MySQL

1. Copy the php_mysql.dll file in the PHP installation directory and the libmysql.dll file in the MySQL installation directory to c:/windows/system32;

2. Configure php.ini

extension=php_gd2.dll

extension=php_mbstring.dll

extension=php_mysql.dll
extension=php_mysqli.dll

Remove the first one of the above four .dlls;

2. Implementation process of submitting PHP form to database

1. login.php page

<span style="font-size:14px;"><html>
<title>login page</title>
<body>



</body>

</html></span>
Copy after login

2. add.php page

<span style="font-size:14px;"><?php
include("conn.php");
?>
<?php
if(isset($_POST["submit"]))
{
    $sql = "insert into users(username, email) values(&#39;$_POST[username]&#39;, &#39;$_POST[email]&#39;)";
	mysqli_query($conn, $sql);
	echo "添加成功";
}
?></span>
Copy after login

3. conn.php page

<span style="font-size:14px;"><?php
$conn = new mysqli("localhost", "root", "159357");
$conn->select_db("db_test");
//mysql_query("set name &#39;gb2312&#39;");
$conn->set_charset("utf8");
?></span>
Copy after login



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/820637.htmlTechArticle1. PHP configuration MySQL 1. Copy php_mysql.dll in the PHP installation directory and libmysql in the MySQL installation directory. Copy the dll file to c:/windows/system32; 2. Configure php.ini extension=php_gd2.dll...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template