Home  >  Article  >  Backend Development  >  用$_POST变量的有关问题

用$_POST变量的有关问题

WBOY
WBOYOriginal
2016-06-13 13:33:35760browse

用$_POST变量的问题
我写了个小程序,但在用$_POST变量时出现了问题。
第一:$_POST["submit"]好像不起作用,点了click就没反应了。
第二:$_POST["user"],$_POST["title"],$_POST["content"]会报错,一定要加大括号,像这样{$_POST["user"]},{$_POST["title"]},{$_POST["content"]},我不明白为什么。
哪位大大帮忙看一下。

include("conn.php");

if($_POST["submit"])
{
$sql="INSERT INTO message (id,user,title,content,lastdate) " .
  "values ('',{$_POST["user"]},{$_POST["title"]},{$_POST["content"]},now())";
  echo "Success";
  $result = @mysql_query($sql,$conn)or die(mysql_error());
}


?>

 


  user:

  title:

  content:


 


 



------解决方案--------------------
HTML code

<?php if(isset($_POST["submit"]))
{
$sql="INSERT INTO message (id,user,title,content,lastdate) " ."values ('','$_POST[user]','$_POST[title]','$_POST[content]','".time()."')";
echo $sql;
  $result = @mysql_query($sql,$conn)or die(mysql_error());
}


?>

  
user:
title:
content:
Statement:
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