PHP is used to connect a web server running on port 80 to a MySQL database server. The process involves the PHP file connecting to the MySQL server using the host, username, and password, selecting the appropriate database, and then sending SQL queries to retrieve results from the database which are then passed back to the web server. Proper sanitization of values is important when sending queries to prevent SQL injection attacks.