您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

$_POST[]有关问题

2025/3/9 6:53:00发布22次查看
$_post[]问题
看php100的视频教程中的留言板部分,里面有句是这么写的:
php codeif($_post['submit']) { $sql = insert into msg (id, userid, contant, oppeardata) values ('', '999', '$_post[contant]', now()); print $sql; $sql_return = mysql_query($sql); if(!$sql_return) { print(发表留言错误).mysql_error(); exit(); } print(发表留言成功);
问题是:$_post['submit']会出错:notice: undefined index: submit in /var/ftp/htdocs/index.php on line 47
submit 是表单按钮的name
$_post[submit]的错误提示 notice: use of undefined constant submit - assumed 'submit' in /var/ftp/htdocs/index.php on line 47
初学,不太明白为啥,和教程里的也对比了,一样的吖。
------解决方案--------------------
php codeif (isset($_post['submit']))
------解决方案--------------------
第一个notice是因为你调用了不存在的变量($_post['submit'])
第二个$_post[submit]是因为你submit两边没有引号引起来,应该$_post['submit']或者$_post[submit]

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product