Repository files navigation
Exercise: HTML form submission
Create a HTML form which allows the input of a first and last name
On submission of the form, send the data to the PHP script
Get the PHP script to display Hello [first name] [last name]
If either the first or last name is null/empty, display an error message.
What is the response status code?
What is the request content type?
Which HTTP method did the request use?
What is PHP doing for us in this very simple application?
What type of "rendering" is at play here?
What alternative implementation could provide the same functionality?
Exercise: handle form submission with JS
Create a script file and link it to your HTML page.
Set up an event listener for the form submission, grab the form values and post them as JSON to your PHP script.
In the PHP script, concatenate your variables and respond with JSON.
Receive the response on the frontend and display back to the user.
Exercise: use the Symfony HttpFoundation for the request and response
Create a Composer file
Use Composer to install the library (hint: Composer can be used in Lando by running lando composer in the terminal)
Include the Composer autoloader in your PHP script
Refactor your existing code to use the Symfony Request and Response objects instead of working directly with PHP globals.
You can’t perform that action at this time.