$ _ POST [] The question is in the message board section of the video tutorial of PHP100. the sentence is as follows: PHPcodeif ($ _ POST [submit]) {$ SQL & quot; insertintomsg (id, userid, contant, oppeardata) values (, 999, $ _ POST [co $ _ POST [] problem
Watch the message board section in the PHP100 video tutorial, which contains the following sentence:
PHP code
If ($ _ POST ['submit ']) {$ SQL = "insert into msg (id, userid, contant, oppeardata) values ('', '123 ', '$ _ POST [contant]', Now () "; print $ SQL; $ SQL _return = mysql_query ($ SQL); if (! $ SQL _return) {print ("message posting error"). mysql_error (); exit ();} print ("message posting successful
");
Problem: $ _ POST ['submit '] error: Notice: Undefined index: submit in/var/ftp/htdocs/index. php on line 47
Submit is the name of the form button.
$ _ POST [submit] error prompt Notice: Use of undefined constant submit-assumed 'submit 'in/var/ftp/htdocs/index. php on line 47
For beginners, I don't quite understand why. it's the same as what I used in the tutorial.
------ Solution --------------------
PHP code
If (isset ($ _ POST ['submit '])
------ Solution --------------------
The first notice is because you call a variable that does not exist ($ _ POST ['submit ']).
The second $ _ POST [submit] is caused by no quotation marks on both sides of your submit. it should be $ _ POST ['submit '] or $ _ POST ["submit"]