PDA

View Full Version : blank database entries


devinemke
4-3-03, 01:32 PM
I run a site (on saturn.powweb.com) that sells subscriptions to a magazine. I have a simple script that collects user data, enters it into a mySQL db and emails me a confirmation. This script has been working fine for over a year now. I recently updated the script to use sessions to store the data across acesses (after initial input, there is a confirmation page where users can see what they entered and make changes before doing a final submit to the db). Since I started with sessions, I have been getting occassional blank database entries; records that are totally blank except for the primary key field (which is auto incremented). I don't understand how this is possible. I have pretty comprehensive form validation going on (via PHP and JavaScript) that make it impossible to submit a blank form. These blanks seem to happen in pairs or sometimes 3 at a time and they all happen in quick succession (within 30 to 60 seconds apart).

It seems as if maybe the session variables are getting lost right before the database entry. Again this problem is intermittant, most of the time the script works fine and I cannot duplicate this problem on my local dev machine. Any ideas? thanx.

HalfaBee
4-3-03, 06:15 PM
Could it be that you form is being Googled? Session ID's won't work when this happens.
Maybe you should put a timestamp field in and you can correllate with your access_log.

HalfaBee

devinemke
4-3-03, 09:44 PM
thanks for the suggestion HalfaBee. Do you mean a spider or robot or something crawling my site?

I do have a timestamp field and I did check it agaist my logs. I can see an access to the subscription script at the same timestamp of the last blank entry. I also see an error in the error_log at the same timestamp that says:
Malformed header: <>... User unknown

the simple fix i put in place is a line of code right before the database entry code that checks to see if $first_name and $last_name are blank and if so end the script and generate an error message.