I have form in webpage where users have to fill in their information and some of them are: birth date, description, education and city. If user add only birth date (or any other field + birth date) and clicks save, than everything is ok, info in database is updated. But if birth date field is left blank then info is not updated and there is an error:
Object Moved
This document may be found here
1292:Incorrect date value: '--' for column 'birth_date' at row 1
UPDATE users SET `avatar` = '01\\14',`birth_date` = '--' WHERE user_id = '13'"
Part of the function where system is checking if fields are empty:
if ( !empty( $Request->post['birth_date'] ) ) {
$user_data['birth_date'] = implode('-', $Request->post['birth_date'] );
}
if ( !empty( $Request->post['description'] ) ) {
$user_data['description'] = $Request->post['description'];
}
if ( !empty( $Request->post['education_id'] ) ) {
$user_data['education_id'] = $Request->post['education_id'];
}
if ( !empty( $Request->post['city_id'] ) ) {
$user_data['city_id'] = $Request->post['city_id'];
}
My question is why this checking if field is not empty does not work for date?
P. S. in mysql database birth_date type is date, description type is text and the other two are integers.