Home > Backend Development > PHP Tutorial > Solution to PHP form submission problem_PHP tutorial

Solution to PHP form submission problem_PHP tutorial

WBOY
Release: 2016-07-21 15:30:43
Original
708 people have browsed it

Make a note of it here, so you can’t fall down in the same place in the future!
The database is bbs and the table is test. The three fields are id, name and sex. The id is auto_increment.
The content of the php file conn.php that connects to the database is

Copy the code 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;

Form page: add2.php. The content is:
Copy code 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 "Success! ";
}
?>






Where was the previous error? $_POST['submit'] $_POST[name] Remember to capitalize it~~~
Is this the syntax? Strange. Just remember it first. You will understand later.
Note: 1.$_POST[] must be capitalized. No matter where.
  2. The submit button must write name and value.name="submit" value = “ ”
  3. The action must be submitted to the php file
  4. Solve the problem of Chinese garbled characters on the page: in the head Write and delete, and add

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323190.htmlTechArticleRecord it here, don’t fall down in the same place in the future! The database is bbs and the table is test. The three fields are id, name and sex. The id is auto_increment. PHP file co...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template