PSA: If you're getting the "Warning: Undefined array key" error, it's because the $_GET variable isn't defined yet when the page first loads. As long as everything else is done correctly, you can ignore it, the form will run fine, and the warning will disappear after the first time you click "submit". As for why the warning doesn't show up for Mike, I'm assuming he somehow turned off error reporting; under normal circumstances, that warning should definitely appear for the code he's written. To those eager to get rid of the warning, you could wrap the PHP code in an "if" statement that checks whether or not $_GET has been set before attempting to print the variable, but Mike hasn't gotten to if statements yet at this point in the series, so maybe that solution would be uncomfortable for some.
you need to make sure that the file name after form action="..." is set to your file's name, not site.php. It has to match the file name of what you're working on.
@@TheMATHEHOUSE That has nothing to do with it. If error reporting is turned on, then the warning will always appear with this code, even if the directory is set correctly. The actual reason the warning appears is because the $_GET variable isn't defined when the page first loads. As long as everything else is done correctly, you can ignore it, the form will run fine, and the warning will disappear after the first time you click "submit".
Please be advised that no one writes forms like this in 2021. I have not written a that posted to PHP in over 6+ years, personally. Please learn JavaScript AJAX forms and use PHP to catch and process the data.
Please help me to rectify this issue. I can't find out my mistake but it is showing "Undefined index:" Name: Notice: Undefined index: name in C:\xampp\htdocs\www\Story.php on line 13
Hi, I'm Wondering if someone can help me. I have a simple task for my college course: how could I make an if statement that checks to see if the name is some value(a particular name) before sending user to a separate php page? Thank you
so i understand the $_GET functions, but lets say i want that input information to carry over to a separate file, so example a series of prompts each one in separate file, then on the last page, i wanna each out a summary of all the inputs, kinda like an order summary
$_GET grabs the data from the HTML form, what determines what happens to that data actually precedes $_GET. In this case, the command was "echo", which basically told PHP to print the data on the page. To save it into a file you can use a command like file_put_contents.