Html-php get form data

Source: Internet
Author: User
I have two php questions: add. php: {code ...} action. php: {code ...} why does the following error occur when submitting data: {code ...} not all namesexargeclassId are available. Why are they still undefined ?? I have two php questions
Where
Add. php:

Action. php:

Switch ($ _ GET ['action']) {case "add": $ name = $ _ POST ['name']; $ sex = $ _ POST ['sex ']; $ arge = $ _ POST ['arge']; $ classId = $ _ POST ['classid']; $ SQL = "insert into students VALUES (NULL, '{$ name}', '{$ sex}', '{$ arge}', '{$ classId }') "; $ rw = $ pdo-> exec ($ SQL); if ($ rw> 0) {echo" script alert ('added successfully'); window. location = 'index. php 'script ';} else {echo "script alert ('failed to add'); window. history. back (); script ";} break ;}

Why does the following error occur when submitting data:

Notice: Undefined index: name in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 16Notice: Undefined index: sex in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 17Notice: Undefined index: arge in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 18Notice: Undefined index: classId in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 19

Name sex arge classId? Why are there still undefined ??

Reply content:

I have two php questions
Where
Add. php:

Action. php:

Switch ($ _ GET ['action']) {case "add": $ name = $ _ POST ['name']; $ sex = $ _ POST ['sex ']; $ arge = $ _ POST ['arge']; $ classId = $ _ POST ['classid']; $ SQL = "insert into students VALUES (NULL, '{$ name}', '{$ sex}', '{$ arge}', '{$ classId }') "; $ rw = $ pdo-> exec ($ SQL); if ($ rw> 0) {echo" script alert ('added successfully'); window. location = 'index. php 'script ';} else {echo "script alert ('failed to add'); window. history. back (); script ";} break ;}

Why does the following error occur when submitting data:

Notice: Undefined index: name in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 16Notice: Undefined index: sex in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 17Notice: Undefined index: arge in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 18Notice: Undefined index: classId in /Applications/XAMPP/xamppfiles/htdocs/studentsManager/action.php on line 19

Name sex arge classId? Why are there still undefined ??

The error behind you is that you open your own in the address baraction.php?action=addIs it displayed?
When you open youraction.php?action=addIt is requested in GET mode, and there is noPOSTSo at this time$_POST['xxx']PHP will haveNotice(When display is allowed ).

Normally from youradd.phpClick the button (when the page data is filled in). The problem you mentioned is not reported.

  • -If the problem is not found, I find that the case can be used for the first time. Isn't it afraid of errors?

The encoding attribute is not set for form.

Encoding = 'application/x-www-form-urlencoded'

That's it. Var_dump ($ _ POST) first );

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.