Delete Data File in PHP
<?php include 'header.php';
if(isset($_POST["sid"])) {
include "config.php";
$stu_id = $_POST["sid"];
$sql = "DELETE FROM student WHERE sid = {$stu_id}";
if($conn->query($sql) == TRUE) {
echo "Record deleted Successfully";
}
else {
echo "Error deleting record : " . $conn->error;
}
header("Location: http://localhost/crud/index.php");
$conn->close();
}
?>
<div id="main-content">
<h2>Delete Record</h2>
<form class="post-form" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<div class="form-group">
<label>Id</label>
<input type="text" name="sid" />
</div>
<input class="submit" type="submit" name="deletebtn" value="Delete" />
</form>
</div>
</div>
</body>
</html>
Comments
Post a Comment