Tuesday, 22 September 2009

Week 7 Prac (done in week 9)

Tonight I was playing catch up on the week 7 prac.

Here are the links to the files, and also a few comments about the process.


1). PHP Example
http://www-student.it.uts.edu.au/~twade/pracs/week7/echo.php
This one was quite simple. I just copied the file onto my web server and it worked :-)

2). Guestbook
http://www-student.it.uts.edu.au/~twade/pracs/week7/gb.php

Here's the steps I followed to get my guestbook working:
  • Created a table in phpmyadmin, using Alastairs SQL query (comments in gb.php)
  • Added my server name, database name, user name and password to the variables in gb.php
  • Uploaded the file to my web server
I found out that the server name doesn't need the "http://" prefix (this caused an error to begin with). I also had incorrectly entered the table name in the database name variable - I hadn't realised that the code already referred to the guestbook table.

To begin with, we were concerned about saving our SQL password in the php file, but after talking to Alastair remembered that the password wouldn't be displayed in the file online, as the web server runs the php scripts first, and then only presents the html code when someone tries to view the source code.

To make the prac simpler, I decided to work on the UTS web server. I might try the same exercise on my 000webhost account, to compare the phpmyadmin tool.

3). Guestbook with Country field added
http://www-student.it.uts.edu.au/~twade/pracs/week7/country/gb.php

Here's what I did to add a new field callled "country"
  • Added a new field called "country" to the table in phpmyadmin, and edited the existing record (adding country details)
  • Looked for all references to the field names in gb.php, and added the new field "country" in a similar manner.
The first time I forgot to add it to the HTML form, so the country field didn't appear in the form, but this was pretty easy to fix.

I haven't done the extra challenge yet, might do it later from home.

No comments:

Post a Comment