MMDT1146 PHP Programming
Week 7


Week 7

Notes:

  • phpMyAdmin can perform any functions that you would need to do to your MySQL database.
  • The Dreamweaver database Application wizards usually break once a person starts modifying the php code that the wizard created.

Connecting Dreamweaver to your MySQL database (compliments of Lavonne Hansen):

  1.  Create administration users for your DB
    • Go to yourwebsitename.info/cpanel and login.
    • Go to Databases>MySQL databases and set up user
      • Create the user  e.g. admin  ( note the user name is lastnfir_admin)  Your account name prepends the username just created.
      • Add user to the database
      • Give full permissions

  2. Give permissions in RemoteMySQL to allow IP addresses to connect to the database
    • Go to yourwebsitename.info/cpanel
    • Go to Databases>RemoteMySQL
    • Add access host ( use the % and click Add Host).  This allows any IP address to connect to the database. Restrict this to just the IP address of your website for security reasons.

  3. Set up test server in Dreamweaver
    • Go to Window>database to bring up the database window
    • In the database window, click the Server behaviors tab
    • Click on the “select site Testing server “ link

    Note the URL prefix at the bottom of this dialog box – take off the trailing public_html

    Testing Server

  4. Create the connection In Dreamweaver
    • Database tab select the + sign (upper left) select MySQL connection
    • The username  and the database have the account name appended

     


Lab 7

This lab is to test your knowledge of being able to create PHP pages that display the data in your customer database, being able to add new customers, and to be able to delete customers.

Create a subfolder on your web server named "contacts".  (This may already be done for you from doing the in class exercises.)

Under the subfolder "contacts" that you just created, you will need to create several files.  The names are of your choosing.  In my example, I called them "form.php", "add.php", "delete.php", and "edit.php"..

The lab must contain several items. 

Your resulting output should like similar to this.

Title your pages.
Put captions on the top of your pages.
Add a background.

On the first page.  I named mine "form.php". :

  • Display the records of your customer table approximately 5 - 10 records at a time.
  • Set up paging links.
  • Set up a recordset count.
  • Create a form.
  • On the form allow the user to be able to sort by geographic location and name.  (Hand coding required)

Create a php file to add users.  I named mine "add.php".:

  • Be able to add customers to your customer table.  You should be able to enter all fields, EXCEPT the ID field.  The ID field is autogenerated/incremented.
  • Have the page reload itself to add multiple customers in succession.
  • Have a link to return to the customer list.
  • Hint:  You may need to use phpMyAdmin to allow "null" fields for some fields that you don't feel are neccessary to be filled out.

Create a php file to delete a customer.  I named mine "delete.php".:

  • Before actually deleting the customer, confirm the deletion first.  Do this by making another variable that you check for and pass as a $_GET variable.
  • After you delete the customer record, go back to the main customer listings.

Create a php file to edit users.  I named mine "edit.php".:

  • Be able to change a customer record.  You should be able to edit all fields, EXCEPT the ID field.
  • Have a link to return to the customer list.
  • Hint:  You may need to use phpMyAdmin to allow "null" fields for some fields that you don't feel are neccessary to be filled out.

Assignment is due 1 week from when it was assigned.  50% penalty if late.

MMDT1146 Lab 7
Grading Criteria
Date
Possible
Points
25
Your
Points
25
Display of customer records.  (form.php) 4 4
Paging Links.  (form.php) 2 2
Recordset count.   (form.php) 2 2
Able to add customers.   (add.php) 4 4
Page reloads itself in succession. (add.php) 1 1
Confirmation of deletion of a customer. (delete.php) 4 4
Deletion of a customer.  (delete.php) 4 4
Edit record of a customer.  (edit.php) 4 4