I have a PHP/HTML form, which should be able to allow the user to change the status of an item to either Active or Inactive. When I submit the form, my success message appears, but the query does not execute. The file name is editStatus.php
I've tried changing around some syntax in the MySQL query, but to no avail.
<html>
<head>
<meta charset="utf-8">
<title>Edit Status | Apparel</title>
<link href="inventoryManagerStyles.css" rel="stylesheet">
</head>
<body>
<h1>Edit Status | Apparel</h1>
<table>
<tr>
<td class="applyFont">
<form action="editStatus.php" method="POST">
STATUS: <input type="text" name="isActive"
placeholder="Active/Inactive" required><br>
</td>
</tr>
<tr>
<td>
<input type="submit" name="update"
value="Update Status" class="submitBtn">
</form>
<a href='viewApparel.php'><button
class='button'>Back</button></a>
</td>
</tr>
</table>
</body>
<?php
if(isset($_POST['update'])) {
//Connect to DB
$hostname = "hostname";
$username = "username";
$password = "password";
$dbName = "dbName";
$con = mysqli_connect($hostname, $username, $password,
$dbName);
//Get Value From User
$isActive = $_POST['isActive'];
$ID = $_POST['ID'];
//Query to Update Data
$query = "UPDATE `Apparel` SET `isActive`='".$isActive."'
WHERE ID='$ID'";
$result = mysqli_query($con, $query);
//Check if Query Was Successful
if($result) {
echo "Status updated to $isActive";
} else {;
echo "Error updating the status of the item.";
}
//Disconnect From DB
mysqli_close($con);
}
?>
</html>
I'd love to get some insight on how I can get this query to actually change the status of the item to Active/Inactive.