I'm still new at php (just started yesterday) and when I wanted to delete my data it says this
Notice: Undefined index: bookname in C:\wamp64\www\HelpingClass\delete.php on line 13
Notice: Undefined index: quantity in C:\wamp64\www\HelpingClass\delete.php on line 14
Notice: Undefined index: price in C:\wamp64\www\HelpingClass\delete.php on line 15
and this is my code for line 13,14,15
$bookname = $_POST['bookname'];
$quantity = $_POST['quantity'];
$price = $_POST['price'];
I even try to change those 13,14,15 lines to this
if(isset($_POST['bookname']) && isset($_POST['bookname'])){
echo $_POST['bookname'];
}
if(isset($_POST['quantity']) && isset($_POST['quantity'])){
echo $_POST['quantity'];
}
if(isset($_POST['price']) && isset($_POST['price'])){
echo $_POST['price'];}
the notice undefined index are gone but i still can't delete the data :(
this is my full code for delete.php
<?php
include ('connection.php');
session_start();
if (!isset($_SESSION ['userid'])&& empty($_SESSION['userid'])){
header ("location:login.php");
exit;
}
else {
$userid = $_SESSION ['userid'];
}
$bookid = $_GET['bookid'];
$bookname = $_POST['bookname'];
$quantity = $_POST['quantity'];
$price = $_POST['price'];
$query = mysqli_query ($conn, "DELETE FROM book SET WHERE Book_Id='$bookid';");
if ($query == TRUE)
{
echo "<script language='javascript'>";
echo "alert('Deleted.');";
echo "window.location.href='action.php';";
echo "</script>";
}
else
{
echo "<script language='javascript'>";
echo "alert('Delete Failed.');";
//echo "window.location.href='action.php';";
echo "</script>";
}
?>
I really do appreciate your help