In my application in-spite of the strict validation on client and server side both, somehow it’s happen that record is going blank from user registration page. All data is blank accept the default value in my table (eg. Gender – Male). This happens approximately 1 in 100 registration.
Mysql – I have structure like not null for every required field. Still it’s inserting blank.
Cakephp side – I am checking data array is blank or not before saving it.
I will really appreciate if anyone help me out.
Thanks in advance.
It’s blank because in every database (except Oracle) an empty string
''is not null. Therefore the database will accept that.If you want to prevent this from happening you need to write a trigger like so:
Alternatively you can make gender a enum field
Links:
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
http://dev.mysql.com/doc/refman/5.5/en/triggers.html