I have a question about deleting data from SQL by using php form.
My php form is something like this:(it's just HTML I guess)
<html>
<body>
<form action="delete.php" method="get">
Uporabniško ime <input type="text" name="user"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
and then I have code that should delete from my sql called delete.php:
<?php
$servername = "localhost";
$username = "test";
$password = "test";
$dbname = "iss";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user = $_POST['user'];
/*if (is_int($_GET['up_ime'])
$query = "DELETE FROM uporabniki WHERE up_ime = " . $_GET['up_ime'];
$result = mysqli_query($con, $query);
// Check the result and post confirm message
}*/
$sql = "DELETE FROM iss.uporabniki WHERE uporabniki.up_ime = " .$_POST['user'];
?>
In my sql database I have DB called "iss" and table "uporabniki". up_ime is Unique and is basicly username. So I'm trying to make form, where I can write username, and when I click submit, that user should be deleted from SQL database. I have no idea what I'm doing wrong and why this isn't working.