I have a registration form built in dreamweaver designed to insert data into my database through PHP, with some of the fields in my form optional to the user.

My understanding is that I should set these 'optional fields' to NULL in mysql in order to be able to proceed with the registration should the user choose not to enter any data. This appears to work fine and the website moves on as required upon the form being submitted.

However, should the user choose to enter something into one of these fields marked NULL in mysql the data is lost and when I look at the inserted row it simply says NULL, regardless of what data the user has entered in the form.

If I go the other way and mark the field NOT NULL then the data appears correctly, only for the user to get an error message saying 'column cannot be null' should they decide to leave it blank.

I am a relative newbie to the world of PHP and mysql so am probably missing something simple. Any help would be much appreciated.

Thanks in advance.