Thursday, August 28, 2008

Last Week

This week has been extremely frustrating in terms of getting the site to where I want it. I had planned to spend this last week working on making the site more presentable and looking good, but that has gone out the window now.

I am still struggling with the final form function - the Submit a Recipe Form. I had set up a time for Phil to sit down with me and go through it, but he pulled out at the last minute and can't see me till Friday night. So I have spent some of this week trying to work it out on my own (in between finishing off a 2,500 word essay for another unit). I know I have the bones of it right, but there is obvously something amiss somewhere.

Next day....

I posted an explanation of what I wanted to achieve on the forum and got some suggestions. Most of them were things that I had already tried or was about to try. But at least I still had some avenues t pursue, so I started looking at breaking the functions down and trying to get one thing going at a time.

Then Peter got on Yahoo and we worked on it for about 3 hours (what I would do without him I never know). Here is an explanation of what was changed

1. Solving the form validation problem:

This was the first thing that we looked at. After some trial and error Peter pointed out that I did not have a line in there to recognise the submitted function.

eg. input type="hidden" name="submitted" value="TRUE" /

So that went in at line 277 of the submit.php page

This finally got the form validation going.

2. Solving the SELECT and INSERT $query for the user_id, recipe_year_id, and category_id issues. I had been trying lots of different things to get this working, but of course nothing was working up till now because I wasn't even getting past the form validation (hence the idea to break things down into smaller functions).

Anyway, I figured that if I included the username in the form then I could SELECT the user_id FROM the user table WHERE user_name=$un.

Peter questioned me on this part of my coding and suggested that we could discard the username part of the form and just call up the session (since the user would be logged in to submit a form). So at line 58 we placed:

$un = ($_SESSION['user_id']) ;

and then set the query to SELECT user_id FROM user WHERE user_name=$un

After a bit of shuffling things around and adding some ; and ' and } it all started to fall into place. Piece by piece I got the database to record all the information in the right order, with all the right id's, and finally the timestamp working.

I wanted to cry!!! Well, actually I did, but I'll deny it now :-)

How sweet it is when you crack something that you have literally been working on for weeks. I love going in there now and entering a new recipe and seeing the results. Oh the power!!!!

No comments: