PHP web application questions
Questions about how a PHP app is put together, from request to response.
The browser sends a POST request; PHP fills $_POST; the script validates, acts (often a prepared INSERT), and either redirects (Post/Redirect/Get) or renders a response.
So a refresh does not resubmit the form and create a duplicate record. Redirect to a GET page that shows the result.
Both pull in a file. require stops the script if the file is missing; include only warns. Use require for files the app cannot run without.
session_start() reads a session id from a cookie, loads that user's data into $_SESSION, and saves it at the end of the request. Regenerate the id on login.
Model (data), View (templates), Controller (request handling). It keeps database code out of HTML and makes each part testable. Laravel and Symfony follow it.
Never in plain text. Use password_hash() to store and password_verify() to check. The hash includes its own salt.
Practise out loud. Say each answer once as written, then again in your own words with your own number or story.
Have a number ready. "My PHP score is at benchmark on a timed test" is a stronger answer than "I am good at it". Take the test and quote the result.
More in Programming