users register to site. admin will login & see list of users.
I am trying to give an option for admin to select checkbox and change status of user through Dropdown submit. when i tried below code i can able to select "Y/N/A" , after clicking submit
button its displaying message "Added Successfully" , but its not updating values in database.
table name : tbl_users , column : userStatus [enum] , values : Y, N, A
form
<form method="post" action="ajax1.php">
<select name="userStatus">
<option value="N">N</option>
<option value="Y">Y</option>
<option value="A">A</option>
</select>
<button type="submit" name="submit" >Submit</button>
</form>
ajax1.php
if(isset($_POST["submit"]))
{
$userStatus=$_POST["userStatus"];
$conn = new Database();
$stmt = $conn->dbConnection()->prepare("INSERT INTO tbl_users (userStatus) VALUES ('$userStatus')");
echo " Added Successfully ";
}
code to display users checkbox, id, name ,email :
$stmt = $user_home->runQuery("SELECT * FROM tbl_users");
$stmt->execute(array(":uid" => $_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->execute();
$status = array('Y'=>'Verified','N'=>'Not verified' , 'A'=>'Approved');
echo "<table>";
echo "<tr>
<td></td>
<td>id</td>
<td>name</td>
<td>email</td>
</tr>";
while($data = $stmt->fetch())
{
echo "<tr>
<td> <input type='checkbox' > </td>
<td>" . $data['userID'] . "</td>
<td>" . $data['name'] . "</td>
<td>" . $data['email'] . "</td>
</tr>";
}
echo "</table>";
i researched & tried lot before posting question, in some links i saw we need to use Javascript, but in some other links, they mentioned we can achieve only with php. i am very new to coding, please help me
Edit
after following below answer , i updated code as $stmt = $conn->dbConnection()->prepare('UPDATE tbl_users SET userStatus = ? WHERE userID = ?');