PHP
PHP is a server-side scripting language.
It was mainly developed for the web but can also be used as a general-purpose programming language.
PHP works well with MySQL and can be used in combination with HTML to create a webapp that connects to a database.
Working:
web browser sends HTTP requests and receives HTTP responses
PHP script (on the server-side) connects to DBMS and uses query results to produce its output
web server calls the PHP script and incorporates its output into the response
web browser renders the HTML document from the response
Executing SQL from PHP:
connect to server (mysql_connect)
select the database (mysql_select_db)
run query
retrieve row of results (mysql_fetch_array)
retrieve attributes (foreach)
A typical web-app will have the following components:
Login page:
Collect credentials and pass them to setup page via POST
Setup page:
Check credentials
Initialize session and session variables
Redirect to welcome page
Application pages:
Call session_start(), authenticate the session, and use/ update session variables, as needed
Logout page:
Calls session_destroy()
Redirects to “goodbye” page
Last updated