Home > Backend Development > PHP Tutorial > $_POST[]有关问题

$_POST[]有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:35:30
Original
962 people have browsed it

$_POST[]问题
看PHP100的视频教程中的留言板部分,里面有句是这么写的:

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->if($_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("发表留言成功"); 
Copy after login


问题是:$_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 code
if (isset($_POST['submit']))<br><font color="#e78608">------解决方案--------------------</font><br>第一个notice是因为你调用了不存在的变量($_POST['submit'])<br><br>第二个$_POST[submit]是因为你submit两边没有引号引起来,应该$_POST['submit']或者$_POST["submit"]<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
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
Latest Issues
Why can’t my submit button submit data?
From 1970-01-01 08:00:00
0
0
0
Ajax click submit but no response!
From 1970-01-01 08:00:00
0
0
0
Click submit but nothing shows up
From 1970-01-01 08:00:00
0
0
0
git submit issue
From 1970-01-01 08:00:00
0
0
0
angular.js - angular's ng-submit does not trigger
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template