I am unable to delete my data from a database through PHP code, though I can from phpmyadmin. I have attached both of my PHP and HTML. I tried to use the same code which is used by phpmyadmin, but there is no progress. Even with this, I am not getting alert message which I use to debug and there is no outcome.
<?php
$conn2=mysqli_connect("localhost","root","") or die(mysql_error());
mysqli_Select_db($conn2,"editor") or die("connot connect to the database");
if (isset ($_GET ['delid'] ) ) {
$deluser=$_GET['delid'];
$alertMessage = "<div class='alert alert-danger'>
<p> Are you sure you want to delete this record?</p><br>
<form action='".htmlspecialchars($_SERVER['PHP_SELF']). " ?id=$deluser' method='post'>
<input type='submit' class='btn btn-danger' id='con_del' name='con_del' value='Yes' delete!>
<a href='location.. /listNB.php' class='close' data-dismiss='alert' aria-label='close'>X</a>
</form>
</div>
";
}
if (isset($_GET['con_del']))
{
$entry_id= $row["entry_id"];
$sql= "DELETE FROM `editornb` WHERE `editornb`.`entry_id` = '".$entry_id."'";
$que= mysqli_query($conn2,$sql);
if ($que) {
print'<script> alert("Sucessfully deleted!!!");</script>';
} else{
print'<script> alert("error");</script>';
}
}
?>
!DOCTYPE html>
<html>
<head>
<title> CK EDITOR </title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="fontawesome/fontawesome-free-5.0.6/web-fonts-with-css/css/fontawesome.min.css">
<script src="ckeditor/ckeditor/ckeditor.js" type="text/javascript" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
<?php
if (isset($alertMessage))
echo $alertMessage;
?>
<br>
<a class="btn btn-success" href="textareaNB.php"> Home </a>
<a class="btn btn-success" href="ListNB.php">List</a>
<br><br>
<table class="table table-striped table-bordered">
<tr>
<th> ID</th>
<th> DATE</th>
<th> Content</th>
<th> Update</th>
<th> Delete</th>
</tr>
<?php
session_start();
$user=($_SESSION['u_uid']);
$query="SELECT * FROM `editornb` where user_uid='".$user."'";
$result= mysqli_query($conn2, $query);
$result_check= mysqli_num_rows ($result);
$date=date("M/d/y");
if ( $result_check > 0 )
{
while ($row= mysqli_fetch_assoc($result)){
echo "<tr>";
echo "<td>" .$row["entry_id"]."</td>";
echo "<td>" .$row["date"]. "</td>";
echo "<td>" .$row["content"]."</td>";
echo '<td><a href="update.php?upid='.$row['entry_id'].'" type="button" class="btn btn-primary btn-sm">
<span class="fa fa-edit"></span> </a></td>';
echo '<td><a href="ListNB.php?delid='.$row['entry_id'].'" type="button" class="btn btn-danger btn-sm">
<span class="fa fa-trash"></span> </a></td>';
echo"</tr>";
}
}
?>
</table>
</booy>
</html>
</div>