I'm a beginner so tell me if i'm doing something fundamentally wrong. I am trying to post data with ajax. The post itself works, but it is not passing any data.
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type: 'POST',
url: 'processwifi.php',
data:{'postid': postid},
success: function(response){
alert('it works');
}
});
});
});
</script>
And the processwifi.php
<?php
$id = isset($_POST["postid"]);
$link = new mysqli("127.0.0.1","***","***","secretariaat");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$sql = "UPDATE wifi SET gebruikt='1' WHERE wifi.id='$id'";
if ($link->query($sql) === TRUE) {
echo "Update of record is '$id' successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
mysqli_close($link);
//Redirect result page
//header('HTTP/1.1 301 Moved Permanently');
//header('Location: wificode.php');
?>
Could anyone help me ?
Many thanks in advance.