I have tried number solutions and cannot figure out what I am doing wrong.
I have the following input element:
<input type="checkbox" data-layout="fixed" class="pull-right" value="1">
just before my closing body tag I have the following jquery
<script>
$("input[type='checkbox']").on('click', function(){
var checked = $(this).attr('checked');
if(checked){
var value = $(this).val();
$.post('mysqlfunc.php', { value:value }, function(data){
if(data == 1){
}
});
}
});
</script>
In mysqlfunc.php file I have
<?php
include "../../inc/config.php";
include "../../inc/funcs.php";
@mysql_connect($dbhost,$dbuser,$dbpass);
@mysql_select_db($dbname) or die( "Unable to select database");
include "../../inc/userauth.php";
if ($_POST && isset($_POST['value'])) {
$value = mysql_real_escape_string($_POST['value']);
$sql = "UPDATE members SET fixed = '".$value."' WHERE username='".$_SESSION['uid']."'";
} else {
}
?>
My expectation is when I click the input checkbox, a value "1" is saved into the "members" table in the "fixed" column where the username is equal to the session uid.
I can echo the uid, so that is working. Its not giving any errors, so its connecting to the database it seems. Yet checking the input textbox, does not change the value in the database.
I get no js errors at all, I get no php errors, just not saving.
What am I doing wrong? Example working code if at all possible would be very helpful.