Skip to content
Advertisement

isset() is not working as wishing in php form [closed]

I want to access a variable from $_GET in a php form but isset is not working as expect to fulfill my request

When I remove the isset() function and set an echo it showing the value but I need to validate the value using an isset(). I can’t find out what’s happening

Here is my code:

<a href="delete.php?delete=<?php echo $rows ['isbn'] ;?>" class="btn btn-danger ">delete</a>

and here is where I access the delete value

if (isset($GET['delete'])){
  $id = $_GET['delete'];
  $query="DELETE FROM books WHERE isbn=$id";
  mysqli_query($con,$query);
  header("Location: /Login/welcome.php");
  exit(0); 

 }

When I simply echo the $GET['delete'] value before the if clause it prints the value properly, but it doesn’t go through the if clause

Advertisement

Answer

First, I recommend using POST method on such action (deletion) as with that you will avoid SQL Injection, And your code mistake is on spelling ($_GET inside isset function not $GET)

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement