无法使用ajax和php更新数据库信息

时间:2015-01-09 19:55:00

标签: php jquery ajax

我正在尝试使用ajax序列化我的表单,然后更新数据库。我在我的数据库中检查了SQL查询,它运行正常。我认为问题在于表单的序列化。我注意到了一个错字,并认为可以解决它,但事实并非如此。我做错了什么?

请参阅HTML& jQuery代码:http://jsfiddle.net/1t3gaz2k/

PHP代码     

$parcel_id = isset($_POST['parcel_id']) ? $_POST['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';

}

?>

1 个答案:

答案 0 :(得分:1)

您引用了GETif(isset($_GET['parcel_id'])) {

看起来您应该查看POSTif(isset($_POST['parcel_id'])) {

没有错误,因为它没有超过您的if声明。