Html如何写MySQL数据库
用网站来注册MC服务器账户,用的是AuthMe登录插件,不知道怎么弄网站:注册AuthMe:登录...
用网站来注册MC服务器账户,用的是AuthMe登录插件,不知道怎么弄
网站:注册
AuthMe:登录 展开
网站:注册
AuthMe:登录 展开
1个回答
2015-12-08
展开全部
form通过submit提交之后
在php端根据$_POST['name']方式获取到对应的表单内容,然后在通过insert方式添加到数据库就可以了啊。。
参考这里:http://www.w3school.com.cn/php/php_mysql_insert.asp
以下是代码:
1
2
3
4
5
6
7
HTML:
<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$con = <a href="https://www.baidu.com/s?wd=mysql_connect&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4P1PWrjRvuH-WnHf3myFW0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtdPHn1rjb4nWb3rjfLrjckP1c" target="_blank" class="baidu-highlight">mysql_connect</a>("localhost","peter","abc123");//连接数据库
if (!$con){
die('Could not connect: ' . mysql_error());
}
<a href="https://www.baidu.com/s?wd=mysql_select_db&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4P1PWrjRvuH-WnHf3myFW0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtdPHn1rjb4nWb3rjfLrjckP1c" target="_blank" class="baidu-highlight">mysql_select_db</a>("my_db", $con);//打开数据库
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";//插入数据
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}echo{
"1 record added";
}
mysql_close($con);
?>
在php端根据$_POST['name']方式获取到对应的表单内容,然后在通过insert方式添加到数据库就可以了啊。。
参考这里:http://www.w3school.com.cn/php/php_mysql_insert.asp
以下是代码:
1
2
3
4
5
6
7
HTML:
<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$con = <a href="https://www.baidu.com/s?wd=mysql_connect&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4P1PWrjRvuH-WnHf3myFW0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtdPHn1rjb4nWb3rjfLrjckP1c" target="_blank" class="baidu-highlight">mysql_connect</a>("localhost","peter","abc123");//连接数据库
if (!$con){
die('Could not connect: ' . mysql_error());
}
<a href="https://www.baidu.com/s?wd=mysql_select_db&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4P1PWrjRvuH-WnHf3myFW0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtdPHn1rjb4nWb3rjfLrjckP1c" target="_blank" class="baidu-highlight">mysql_select_db</a>("my_db", $con);//打开数据库
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";//插入数据
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}echo{
"1 record added";
}
mysql_close($con);
?>
追问
小白,能不能讲详细点?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询