user11119483
user11119483

Reputation: 13

jQuery code not updating fields in database or updating dropdown

I know that the PHP scripts work because I tested them without jQuery therefore I think something wrong with my jQuery.

<form id="bakery" name="bakery" method="POST" action="bakeryupdate.php">
            <select id="bakeryid" name="bakeryid">
                <option value="">Select</option>
                </select>
<input type="submit" value="Submit" name="submit" id="bakeryupdatebutton" />
</form>

$(document).ready(function() {

        $.ajax({
            type:'POST',
            url:'bakeryupdate.php',
        data: {bakeryid:bakeryid}
        }).done(function(){
            $('#success').text('success!');

        });
    }
        e.preventDefault();
        });    
});

update data php script

<?php       
    if(isset($_POST['submit'])) {

        $sql = "UPDATE bakeryorders SET description='shipped";

        if (mysqli_query($con, $sql)) {

            echo "Bakery order updated";
        } else {
            echo "Error!";
    }
}
?>

Upvotes: 0

Views: 98

Answers (1)

Jean-Fran&#231;ois Savard
Jean-Fran&#231;ois Savard

Reputation: 21004

Make sure to commit the transaction if you don't have autocommit...

mysqli->commit();

Upvotes: 1

Related Questions