I am trying to write PHP code that will increase the count by 1 when the user clicks RSVP. As of now, when I click the RSVP button I get a message that says that the RSVP was successful but when I check the database the RSVP count is still 0. Here is the code that is supposed to carry out this function.
<?php
$servername = "db.sice.indiana.edu";
$username = "i494f20_tywinfre";
$password = "my+sql=i494f20";
$dbname = "i494f20_tywinfre";
// Create Connection
$conn = mysqli_connect("db.sice.indiana.edu", "i494f20_tywinfre",
"my+sql=i494f20_tywinfre", "i494f20_tywinfre");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$id = $_POST["EVENTID"];
$sql = "SELECT CURRENTGUEST, MAXGUEST FROM EVENTS WHERE EVENTID
$id";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows ($result) > 0) {
//OUTPUT DATA OF EACH ROW
while($row = mysqli_fetch_assoc($result)) {
if($row['CURRENTGUEST']<$row['MAXGUEST']) {
$id = $_POST["EVENTID"];
$t = $row['CURRENTGUEST'];
$query = "UPDATE EVENTS SET CURRENTGUEST = CURRENTGUEST + 1
WHERE EVENTID = $id";
echo "RSVP successful";
}
}
} else {
echo "Event is full";
}
mysqli_close($conn);
?>
Here is my code I am not sure what the problem could be thank you for the help!