Open Gramericana opened 3 years ago
Hey there Gramericana, Happy new year! 👏🎉
The “undefined index: ‘key’” errors occur when you try to reference a key in an array that is not yet set. It’s a little bit hard to see why this is happening in your case without seeing your code, but there are a few ideas that spring to mind:
1) Make sure you’re loading response.php only after submitting the index.html form. If you try to load response.php directly in the browser, the $_POST array won’t be defined, as it won’t have the form data inside.
2) Make sure your form element has a method attribute of “POST” and an action attribute of “response.php”. (Although - I note you’re using a filename of “response2.php” - is this intentional? Make sure your form ‘action’ attribute matches the response script file name).
3) Make sure that each element has a ‘name’ attribute that corresponds to the corresponding $_POST key (ie last_name, first_name etc).
4) Note that all of these are exactly case sensitive.
If you check all of those things and can’t solve your issue, let me know, and I can take another look.
Josh
Hey Josh +/- community,
Am working on the admitme task but keep coming up with the following after inserting the form under the index.html page and then updating response.php
"Admission Note 2/1/21 14:53
Notice: Undefined index: last_name in /Applications/XAMPP/xamppfiles/htdocs/admitme/response2.php on line 32
Notice: Undefined index: first_name in /Applications/XAMPP/xamppfiles/htdocs/admitme/response2.php on line 32 , Hospital ID: Notice: Undefined index: id in /Applications/XAMPP/xamppfiles/htdocs/admitme/response2.php on line 33 Sex: Notice: Undefined index: sex in /Applications/XAMPP/xamppfiles/htdocs/admitme/response2.php on line 34"
Can't seem to upload screenshots here but let me know if there's a way to add photos and I'll upload what my screens are showing on sublime text.
Any ideas where/how I might be going wrong? Have retraced steps from the chapter but still keep coming up against a wall here.