Strange error re user_id when adding entries to database
I have a simple PHP program and a small MySQL database. When I add a new entry to the database, using a form, I often get the following error: "Undefined index: user_id"
My personal user id in the database is 1. When I get this error, it usually means that the entry has been entered in the database as if from user 0. There is no actual user 0. Sometimes the entry is entered in the database as if from user 0 (who doesn't exist); sometimes as if from user 1 (me). I cannot detect any pattern in when it goes one way or the other.
Does that make any kind of sense to anyone? Is there a way that I could plug this hole so that there would be no future entries attributed to user 0? and a way to ensure that all my future entries are attributed to user 1?
- - - - -
In case it helps, my database looks something like this:
1st table - users:
Code:
Field Type Null Default Auto_increment
user_id smallint(5) No yes auto_increment
email varchar(40) No
password varchar(40) No
first_name varchar(15) No
last_name varchar(30) No
active char(32) Yes
registration_date datetime No
2nd table - temperatures:
Code:
Field Type Null Default
user_idm smallint(5) No
temp_rating char(2) No
notes text Yes NULL
time_entered datetime No
time_entered2 timestamp No
CURRENT_TIMESTAMP