Im makeing something new but i want to make delete file where you can type ID and then click on submit and this function deletes the data from mysql.
Delete.php
<?php
ob_start();
include("db.php");
if(isset($_GET['id'])!="")
{
$delete=$_GET['id'];
$delete=mysql_query("DELETE FROM Osebe WHERE id='$OsebaID'");
if($delete)
{
header("Location:index.php");
}
else
{
echo mysql_error();
}
}
ob_end_flush();
?>
html file with form
<html>
<head>
<meta charset="UTF-8">
<title> TEST </title>
<style>
</style>
<!-- STYLES -->
<link href="css/dodaj.css" rel="stylesheet">
</head>
<body>
<div class="login">
<h1> IZBRIŠI VNOS </h1>
<FORM ACTION="brisi.php" method="post"><br>
ID: <input type=text name="id"><br>
<input type=submit value"Delete"><input type=reset value="Ponastavi>
</form>
</div>
</body>
</html>
Can somebody help me please?
if(isset($_GET['id'])!="")will probably work not like you expect. Isset returns boolean true or false which is then compared to an empty string.WHERE id='$OsebaID'"or do you want to delete the ID passed from the form? (in which case, in addition to the logic error there is an SQL injection vuln).