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!";
}
}
?>
mysqli_real_escape_string()requires DB connection be passed. php.net/manual/en/mysqli.real-escape-string.php - Plus, make sure your submit button has the name attribute. That conditional statement is relying on it.or die(mysqli_error($con))tomysqli_query()and use error reporting php.net/manual/en/function.error-reporting.php - You have enough to debug your code.$bakeryid= mysqli_real_escape_string($con,$_POST['bakeryid'])?