I'm building a site that offers a discount based upon a promo code that the user has the option to enter. It's necessary for me to validate that the code exists in our database before processing a new signup. Here's the AJAX call I'm using for validation:
if (promo_code) {
    var returned = true;
    $.ajax({
        type:    "POST",
        url:     "/ajax/validate_promo_code.php",
        data:    {promo_code: promo_code},
        success: function(result) {
            if (result == 0) {
                $('#blank_dialog_popup').html('<span class="message_text_big">Sorry, that promo code is not valid.</span>').addClass('message_warning').css('display', 'block').css('z-index', '1003');
                setTimeout(returnMessageBackground, 3000);
                $('#promo_code').focus();
                returned = false;
            }
        }
    });
    if (returned != true) {
        return false;
    }
}
And here's the entire PHP file I use for validation.
<?php
//ini_set('display_errors',1);
//error_reporting(E_ALL|E_STRICT);
    $db = new Database();
    $promo_code = filter_var(intval($_POST['promo_code']), FILTER_VALIDATE_STRING);
    $check_query = "SELECT id FROM users WHERE promo_code = '$promo_code'";
    $db->query($check_query);
    if ($db->num_rows != 1) {
        return 0;
    } else {
        return 1;
    }
?>
The success field won't execute, even if I comment out every line of code from the PHP file except for "return 0;" and get rid of the "data:" line in the AJAX call, which makes me think there's something dreadfully wrong with my code, but I can't for the life of me figure out what. Thanks for your help!
 
     
    