Let's Get Started with a PHP/MySQL Form Page!
- Open Notepad++
- Choose:
File -> New
- Copy the PHP Form Template (PHP) code (below)
- Paste that code into your new file
- Change the put-title-of-this-page-here
- Change the lines with the blanks:
$query = "____________________________";
$query .= "____________________________;";
to:
$query = "INSERT INTO dishes (dish_name, price, is_spicy) ";
$query .= "VALUES ('$name', $price, $isSpicy);";
- Click: File -> Save As
- Name your file: webmysqlform.php
- Change the
Save as type:
to: PHP Hypertext Preprocessor (*.php)
- Click: Save
- Start your local web server if it is not already running
- Visit your page (http://localhost/form.php) in your favorite web browser
- Make any changes
- Save your changes
- Fill in the form fields
- Submit your form
- View your
mysqlform.php
page to see if the addition worked
- Change:
$debug = 0;
to: $debug = 1;
- Add another record to see the debug messages
PHP Form Template (PHP)
Output