I really appriciate your help, i am loseing my mind here I don't get any errors, everything seems ok, but the db is not updating?!!!
in firefox consol i get no error and on the server log no error ?!!
i get the alert saying insert successful!! but as i said, my db dosent update?!
here is my code
<div id="landmark-1" data-landmark-id="1">
<form id="insertContact" >
<input name="a1" id="a1" type="text" placeholder="" onFocus="$(this).val('')" value="">
<label> name </label>
<input name="a2" id="a2" type="text" placeholder="" onFocus="$(this).val('')" value="">
<label>message</label>
<input type="submit"
id="submit" name="submit" value="Submit" />
</form>
</div>
and this is my js file
$(document).ready(function(){
$("#submit").click(insertContact);
});
function insertContact(){
console.log("Entering insertContact()");
$("#insertContact :input").serializeArray(),
$.post("update.php",
function(json){
if(json== null || json == 'undefined')
alert("Insert failed");
else
alert("Insert successful");
});
return false;
}
and this is my php file
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
$server = "localhost";
$username = "xxxxxxx";
$password = "xxxxxxx";
$database = "xxxxxxx";
$con = mysql_connect($server, $username , $password) or die ("Could not connect: " . mysql_error());
mysql_select_db($database, $con);
$iid=1;
$ab1 = mysql_real_escape_string($_POST["a1"]);
$ab2 = mysql_real_escape_string($_POST["a2"]);
$sql = "UPDATE my_table SET
field_1='$ab1',
field_2='$ab2'
WHERE id=$iid";
</div>