php表单提交问题的解决方法_PHP

WBOY
Release: 2016-06-01 12:17:17
Original
1031 people have browsed it

在此记录一下,以后不能在同一个地方摔倒了!
数据库为bbs,表为test.三个字段,分别为id,name,sex。id为auto_increment。
连接数据库的php文件conn.php内容为
复制代码 代码如下:
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;

表单页:add2.php。内容为:
复制代码 代码如下:
include("conn.php");
if($_POST['submit']){
$sql="insert into test (id,name,sex) values ('','$_POST[name]','$_POST[sex]')";
mysql_query($sql); echo "成功!";
}
?>







之前的错误在哪?$_POST['submit'] $_POST[name] 记得要大写啊~~~
语法就是这样的吗?奇怪啊。还是先记住吧。以后会明白的。
需要注意的:1.$_POST[]一定要大写。无论在哪。
      2.提交的按钮一定要写上name和value.name="submit" value = “ ”
      3.action要提交到php文件
      4.解决页面中文乱码问题:在head里写删除,加上
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!