created a user login page. Where I can see which user is logged in. But I can’t delete user from database. I am using PDO for connecting database. Here is my method for deleting user:
public function delete($user_name)
{
$sql = $this->connection()->prepare("delete from online where user_name = :user_name");
$sql->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$sql->execute();
return $sql;
}
here is my HTML code:
if(isset($_POST['submit'])){
$user_name = isset($_POST['user_name']);
print_r($user_name);
//call delete method to delete the user from database
$database->delete($user_name);
}
<form action="" method="post">
<?php
foreach($rows as $row){
$time = $row['time_out'];
echo "<input type='text' value='$row[user_name]' name='user_name'>
<input type='text' value=' $row[course]' >
<input type='text' value=' $time '>
<input type='hidden' value='$row[user_name]' name='user_name'>
<input type='submit' value='delete' name='submit'><br>";
}
?>
</form>
$var = function($var)in this case if function returns false/true, $var will become either false or true, but not the value you want