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.
The encoding attribute is not set for form.
Encoding = 'application/x-www-form-urlencoded'
That's it. Var_dump ($ _ POST) first );