The Administrative Side

The first scripts I’ll write will be for the purpose of adding products (specifically a print) to the database. The page will allow the administrator to select the artist by name or enter a new one, upload an image, and enter the details for the print. The image will be stored on the server and the print’s record inserted into the database. But since this will require a script that connects to the MySQL database, I’ll write that first.

To create mysql_connect.php:

Create a new PHP document (Script 13.1).
<?php # Script 13.1 - mysql_connect.php
Define the database connection constants.
 define ('DB_USER', 'username'); define ('DB_PASSWORD', 'password'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'ecommerce'); ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.