Php form submission solution _ PHP

Source: Internet
Author: User
It was not the first time I wrote a form and submitted it, but I still encountered an unsolved problem. After studying for nearly one day, I asked N + netizens and finally solved the problem. The process was rather tortuous. Thank you for your help. Record it here and you won't be able to fall down in the same place in the future!
The database is bbs, and the table is test. three fields are id, name, and sex. The id is auto_increment.
The content of the php file conn. php connecting to the database is
The code is as follows:
$ Conn = @ mysql_connect ("localhost", "root", "") or die ("database link error ");
Mysql_select_db ("bbs", $ conn );
Mysql_query ("set names 'gbk'"); // use GBK Chinese encoding;

Table single page: add2.php. Content:
The code is as follows:
Include ("conn. php ");
If ($ _ POST ['submit ']) {
$ SQL = "insert into test (id, name, sex) values ('', '$ _ POST [name]', '$ _ POST [sex]') ";
Mysql_query ($ SQL); echo "successful! ";
}
?>


Where was the previous error? $ _ POST ['submit '] $ _ POST [name] remember to use uppercase letters ~~~
Is the syntax like this? Strange. Remember it first. I will understand it later.
Note: 1. $ _ POST [] must be capitalized. No matter where it is.
2. the submitted Button must contain name and value. name = "submit" value = "".
3. The action is to be submitted to the PHP file.
4. solve the problem of Chinese garbled characters on the page: write and delete in the head , Add

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.