Home > Backend Development > PHP Tutorial > 新手.小白在此,该如何解决

新手.小白在此,该如何解决

WBOY
Release: 2016-06-13 13:50:01
Original
759 people have browsed it

新手...小白在此
学了三天了,跟着视频写了个简单的,但是......

add.php文件:
 $conn=mysql_connect("localhost","root","123");
 mysql_select_db("test",$conn);
 if($_POST['send'])
 {
  if(mysql_query("insert into totest(username,usertitle,usercontent,date)values('$_POST[user]','$_POST[title]','$_POST[content]',now())",$conn))
  {
echo "发表成功";
  }
  else echo("Mysql error:".mysql_error());
}
mysql_close();
?>
 
Html文件:



我的Test


 

用户:

标题:

内容:








数据库totest表:
   
  userid username usertitle usercontent date
  1 2011-11-18
  2 2011-11-18
  3 2011-11-18
  ............

为什么中间的POST都不能取到值啊?

------解决方案--------------------
$_POST[title]为$_POST['usertitle'].....
要用你的input的name名字......
------解决方案--------------------
你的表单是 name="username" name="usertitle" 而你的php $_POST[user]','$_POST[title]','$_POST[content] 能取到才怪了
------解决方案--------------------
这不丢人!小疏漏而已
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