Tuesday, July 29, 2008

Activation of Registration

I have decided to make this a separate post as there is so much to this issue.

When I innitially made the attempt to register for the firts time I got as far as the activation link within the email before the error trigger showed up and I was not able to activate the registration. The active field of the database showed that there had been a registration with a email, username, and password, but that it had not been activated. the active column showed the #2 under it. Subsequent tries had the same result - all having the #2 in the active column.

I spent a lot of time cleaning up the script and managed to fix up the Parse errors and script errors, but couldn't get the validation to work.

My thinking was that it had something to do with the database setup, but I wasn't sure. Everything validated within the register.php, and it wasn't until the validate.php page was called up that the error message appeared. This said to me that the problem lay in the database structure.

As I studied the script in the activate.php file I felt that I should have to change the Char from (1) to (32), as the '$y' generated a temporary 32 character string which validates the registration, and then it reverts to NULL when the registration is validated. But changing this didn't solve the validation problem. So I was not sure where to look from there.

I did a bit of research on the internet, but couldn't find anything specific enough to solve the problem (Sean, 2007)(student, 2008). So I decided to ask for help on the WebCT forum. I recieved a couple of repsonses and then an email from Peter Martin suggesting we walk through it together on Yahoo Messenger (Maurer, 2008). He spent over an hour with me going through both the register.php script and the activate.php script. I also posted a question on Sitepoint Forums and had a response, but Peter and I had solved it before I could get right into it (Maurer, 2008).

It all came down to two problems. The first one was discovered by Peter:

1. The setting the variable for activate as '$a' on line 40 of the register.php page. I had not properly set it, but had actually set it as NOW(). Which meant I was issuing a date and time to it and not a variable. So I changed it. However, it still didn't solve the problem with the validation, but, both Peter and I felt that we were not far from the solution and that this was part of it.

2. I then mentioned that we probably should change the active field to Char(32) to allow for the 32 character temporary string. I ended up giving it Char(40). This worked a treat and before I knew it Peter had registered and validated.

Since then I believe I also need to change the NULL column to NULL instead of NOT NULL, as once registration is activated the active column reverts from a 32 character string to NULL. The database works the same with it, but still not sure if this is the right thing to do. Will keep looking into it.

Right now I have another problem on my hands. Validation works, but when I try to login after validation I keep getting the error:

Please enter a valid password
Please enter a valid username

So back to the drawing board....

No comments: