1

次のコードがあります。

var url = "save.php"; // the script where you handle the form input.   

$.ajax({
        type: "POST",
        url: url,
        data: $("#frmSurvey").serialize(), // serializes the form's elements.

        success: function(){
            alert('success');
          },
        error: function(){
            alert( "Request failed: " );
          }

        }); 

これで、DB にデータを送信するときに問題なく動作しますが、意図的にsave.phpファイルを変更してデータが送信されないようにしても、successアラートが表示されます。

以下の保存ファイルのコード:

$proc = mysqli_prepare($link, "UPDATE tresults SET ip = ?, browser = ?, q1 = ?, q2 = ?, q3 = ?, q4 = ?, q5 = ?, q6 = ?, q7 = ?, q8 = ?, q9 = ?, q10 = ?, q11 = ?, q12 = ?, q13 = ?, q14 = ?, q15 = ?, q16 = ?, q17 = ?, q18 = ?, q19 = ?, q20 = ?, q21 = ?, q22 = ?, q23 = ?, q24 = ?, q25 = ?, q26 = ?, q27 = ?, q28 = ?, q29 = ?, q30 = ?, q31 = ?, q32 = ?, q33 = ?, q34 = ?, q35 = ?, q36 = ?, q37 = ?, q38 = ?, q39 = ?, q40 = ?, q41 = ?, q42 = ?, q43 = ?, q44 = ?, q45 = ?, q46 = ?, q47 = ?, q48 = ?, q49 = ?, q50 = ?, q51 = ?, q52 = ?, q53 = ?, q54 = ?, q55 = ? WHERE respondent_id = ?;");
    mysqli_stmt_bind_param($proc, "ssiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiissi", $ip, $browser, $q1, $q2, $q3, $q4, $q5, $q6, $q7, $q8, $q9, $q10, $q11, $q12, $q13, $q14, $q15, $q16, $q17, $q18, $q19, $q20, $q21, $q22, $q23, $q24, $q25, $q26, $q27, $q28, $q29, $q30, $q31, $q32, $q33, $q34, $q35, $q36, $q37, $q38, $q39, $q40, $q41, $q42, $q43, $q44, $q45, $q46, $q47, $q48, $q49, $q50, $q51, $q52, $q53, $q54, $q55, $respondent_id);
    mysqli_stmt_execute($proc);
    $mysql_error = mysqli_error($link);
    if ($mysql_error!="") {
        printf("Unexpected database error: %s\n", $mysql_error);
        mysqli_stmt_close($proc);
        mysqli_clean_connection($link);
        exit();
    } else
    {
        mysqli_stmt_close($proc);
        mysqli_clean_connection($link);
        update_completion_status($respondent_id, 'Started');
        header("Location: index.php?r=".$rguid);
    }

どこが間違っていますか?

4

2 に答える 2