$ _ POST [] related questions

Source: Internet
Author: User
$ _ 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"]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.