This code doesn't work! The console.log prints
"You are not subscribed to newsleter"
I want to be able to click the button and then it says
"You are subscribed to newsleter"
This is my HTML
<button onclick="subscribe()">Subscribe to newsletter</button>
This is my script
function subscribe(){
$.ajax({
url: 'php/test.php',
success: function(data){
console.log(data);
}
});
return false;
}
This is my PHP
<?php
$myQUERY ="SELECT * FROM user";
$myQUERY .=" UPDATE user";
$myQUERY .=" SET Subscribed='1'";
$myQUERY .=" WHERE DisplayName='Henry'";
$row = mysqli_fetch_array($result);
if ($row['Subscribed'] == 1) {
echo 'You are subscribed to newsleter';
}
else
{
echo 'You are not subscribed to newsleter';
}
?>
In the Database, newsletter subscription is set to 1 when subscribed and 0 when not subscribed