I am trying to update the database with isset to set the value of the variable to either null or the value entered by the user. Currently, if no value has been entered null is being set as a string causing the date field to populate with zeros. How do I code it so that it populates or sets the value as null and not as string null?
Here's my code: (yes I know sql injections it's still in development )
<?php
require_once('../config.php');
$parcel_id = isset($_GET['parcel_id']) ? $_GET['parcel_id'] : null;
//$appeal_address_match = isset($_POST['AppealAddressMatch']) ? 1 : 0; (add to sql statement -- appeal_address_match='". $appeal_address_match ."',)
$date_appeal_received = isset($_POST['DateAppealReceived']) ? $_POST['DateAppealReceived'] : null;
$bos_meeting_date = isset($_POST['BosMeetingDate']) ? $_POST['BosMeetingDate'] : null;
$late_returns_date = isset($_POST['LateReturnsDate']) ? $_POST['LateReturnsDate'] : null;
$determination_notice = isset($_POST['DeterminationNoticeSet']) ? $_POST['DeterminationNoticeSet'] : null;
$final_determination = isset($_POST['FinalDetermination']) ? $_POST['FinalDetermination'] : null;
$analysis_recommendation = isset($_POST['AnalysisRecommendation']) ? $_POST['AnalysisRecommendation'] : null;
$email_address = isset($_POST['EmailAddress']) ? $_POST['EmailAddress'] : null;
$phone_number = isset($_POST['PhoneNumber']) ? $_POST['PhoneNumber'] : null;
if(isset($_GET['parcel_id'])) {
$db = new ezSQL_mysql(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$result = $db->query("UPDATE parcels SET date_appeal_received='" . $date_appeal_received . "',
bos_meeting_date='". $date_appeal_received ."',
late_returns_date='". $late_returns_date ."',
determination_notice_sent_date='". $determination_notice ."',
final_determination='". $final_determination ."',
analysis_recommendation='". $analysis_recommendation ."',
email_address='". $email_address ."',
phone_number='". $phone_number ."'
WHERE parcel_id='" . $parcel_id ."'");
/*if ($result == TRUE) {
echo '{"success":true}';
} else {
echo '{"success":false}';
} */
if($result) echo 'true';
else echo 'false';
}
?>