Updated 4/22/2020 at 9:10pm
Homework #10: Changing a Database's Contents with PHP
- Remember to follow all the standard Homework Requirements.
- This assignment will demonstrate:
- Receiving HTML form data into a PHP page.
- Inserting the form data into a MySQL table using a SQL INSERT statement.
- Main steps in this assignment:
- Make the PHP code that is the action code for the HTML form that you
made for the
previous assignment, in your Products page. This action code will receive the form variables from the
form, and will use a SQL Insert statement to add a row to
the Products table.
- Upload the updated Products Page to your class Web site.
- Add at least 4 (more) records to your Products table, using your form and action code.
- HINTS:
- The formatting specifier codes which you will need for your sprintf() statement
are these:
- %d -- for integer (whole) numbers (sometimes called "decimal" numbers)
- %f -- for floating-point numbers, meaning numbers with a decimal point in them
- %s -- for strings AND dates
-
If you want to see the complete list of formatting codes, there is a list on the
reference page for sprintf( ) at php.net.
-
You can find some sample "insert" code in the e-handout section "Add", in the SQL Insert page, addnewtrans.php.
But be careful: Not everything in there is needed for your code, and you need to add some code that isn't in there.
In particular: