<?php 
include ("conn.php");
if('$_POST[submit]'){
$sql = "insert into message(id,user,title,content,lastdate)".
"values('','$_GET[user]',$_GET[title],$_GET[content],now())";
echo $sql;
    $arr = @mysql_query($sql)or die("建立失败");
    echo $sql;
    echo "成功";}
?>
<form action = "add.php" method = "get">
用户:<input type = "text" size = "10" name = "user"><br>
标题:<input type = "text" name = "title" /><br/>
内容:<textarea name = "content"></textarea><br/>
<input type = "submit" name = "submit" value = "发布留言"/>
</form>Notice: Undefined index: user in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\bbs2\add.php on line 5Notice: Undefined index: title in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\bbs2\add.php on line 5Notice: Undefined index: content in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\bbs2\add.php on line 5
insert into message(id,user,title,content,lastdate)values('','',,,now())建立失败
数据库连接时正常的  求助

解决方案 »

  1.   

    Notice: Undefined index: title在这些提示前添加变量的判断if(isset($_GET['title']))
    xxxx...
      

  2.   

    if($_SERVER['REQUEST_METHOD'] == "POST") {
      if($_POST['submit']){
         $sql = "insert into message(id,user,title,content,lastdate)".
                "values('','$_GET[user]',$_GET[title],$_GET[content],now())";
         echo $sql;
         $arr = @mysql_query($sql)or die("建立失败");
         echo $sql;
         echo "成功";
      }
    }
      

  3.   

    我不明白 isset($_GET[user])为什么位false, 
    <form action = "add.php" method = "get">
     用户:<input type = "text" size = "10" name = "user"><br>
     标题:<input type = "text" name = "title" /><br/>
     内容:<textarea name = "content"></textarea><br/>
     <input type = "submit" name = "submit" value = "发布留言"/>
     </form> 我明明定义了
      

  4.   

    get方式提交还是post方式提交?
      

  5.   

    最上面用的POST  后来我试了GET  发现isset($_GET[user])都时false,
      

  6.   

    可以看下你的url是不是get的参数,chrome 开发者工具可以看到具体的请求是怎么样发送出去的
      

  7.   

    在不判断isset(user)的时候,有输入框显示,输入后有insert into message(id,user,title,content,lastdate)values('','yu','yu','yu',now())建立失败
    信息,说明$_get[user]时有值的,可是判定却是空,而且 masql_query($sql)也是错误,我真的不知道怎么回事了,跟视频教学上一模一样啊
      

  8.   

    是不是isset($_GET[user])的user要加'',isset($_GET[‘user‘])
      

  9.   

    $sql = "insert into message(id,user,title,content,lastdate)".
     "values('','$_GET[user]',$_GET[title],$_GET[content],now())";$_GET[title]  , $_GET[content]都没有‘’,看看是不是这个原因!