Submitting Form Data as Query Parameters
Let's see how HTML forms can be used to get a user's input.
Why use HTML forms?
We have seen how you can let the PHP server serve PHP scripts.
We also saw how you can provide input to these scripts using query parameters, which are part of the URL.
This works great if the input is something the application produces, like the random number in /random.php
.
But if we want the user to provide the input themselves, we should use an HTML form.
A form is much more user-friendly since the user doesn’t have to modify the URL manually.
They can just type something in a form field, select an item from a combobox, put a checkmark somewhere, and submit the data to the server.
Get hands-on with 1400+ tech skills courses.