CS 315 Homework 5: PHP & Databases
Assigned: 3 November 2017 Due: 15 November 2017
This homework problem is to be done individually, not in pairs or
other groups. Your completed assignment should
be submitted using the Assignment Submission
Page. You should submit a link to a page that has links to both the URLs of the
actual PHP files that run and the URLs of the .phps files with your
source.
- Define a simple SQL database table with three or four columns of
your choosing. For example, you might have LastName, FirstName and
EmailAddress or something equally simple. Your table should have a
primary key that will be unique. This can just be an auto-increment
ID or a timestamp or something. Include the definition (CREATE
TABLE sql) of your table as a comment in some obvious part of the
assignment that you submit.
- Write a program using a single PHP file that presents the user
with a form that allows them to enter whatever kind of data you want
to store in your table, then, when they click Submit, processes the
form, does a thorough security check and cleansing of the data the
user gives you, then (when the data is reasonable) inserts
the data into your database.
- Write another program using a single PHP file that presents the
contents of your database in some appropriate manner. By appropriate
manner I mean that your data should be presented in a way that makes
sense. Be sure to present all of the data. You will almost
definitely want to sort your data by some relevant field. HTML tables
might (or might not) be a good way to present the data.
Your PHP programs should interact with MySQL using the PDO
interface that is described in the book and briefly mentioned on the
class webpage. Do NOT use the mysqli interface or other older
interfaces. Unfortunately, some class webpage examples (and online
Safari books) use these older interfaces. Do not be swayed by
them. Stand firm.
All of your code should be contained in the two .php files. Of course,
be sure to have .phps files as well.