This is my form from my html
<form action="Belo_Connect2.php" method="POST">
<center>
Name:<input type="text" name="namefordelete">
<p> //button that submits to php file
<button><a href="Belo_Connect2.php" target="_self" style="text-decoration: none" method="POST">DELETE</a></button>
</p>
</center>
Now below is my php file that returns Name is empty but I definitely input text when running it on my localhost. Can you guys help me to pinpoint my error here? Thank you so much. And please note if im deleting things right way here. Thank you again
$name = filter_input(INPUT_POST,'namefordelete');
if(!empty($name)){
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "studentInfoDB";
$conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
if(mysqli_connect_error()){
die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_error());
}
//my delete query
else{
$sql = "DELETE FROM studentTbl WHERE Name = '$name'";
if($conn->query($sql)){
echo "One record Deleted!";
}
else{
echo "Error:".$sql."<br>".$conn->error;
}
$conn -> close();
}
}
//this always return even I have an input on my input box from html file name=namefordelete
else{
echo "Name should not be Empty";
die();
}
?>