PHP PDO DELETE BUTTON

Asked at 2017-01-11 09:21:47Z
  • 5 Subscribers
  • 114 Views
-3

I tryed every way but it does not work

option.php

if (isset($_GET['agentsdelete'])) {

$agents_id=$_GET['agents_id'];
$delete=$db->prepare("DELETE FROM agents WHERE agents_id=:agents_id");
$control=$delete->execute(array(
    'agents_id' => $_GET['agents_id']
));

if ($control) {

    Header("Location:agents.php??durum=ok&agents_id=$agents_id");

} else {

    Header("Location:agents.php??durum=no&agents_id=$agents_id");
}

this is php script

index.php

  <a href="option.php?agentsdelete=<?php echo $agentget['agents_id'];  ?>" class="btn btn-danger btn-sm btn-icon icon-left">
            <i class="entypo-cancel"></i>
            Delete
        </a>

and this one is index.php where button in


1 answers in total

0
Masivuye Cokile Posted at 2017-01-11 10:18:53Z
<?php

if (isset($_GET['agentsdelete'])) {

    $agents_id = $_GET['agentsdelete'];



    $delete = $db->prepare("DELETE FROM agents WHERE agents_id= ? ");

    if ($delete->execute(array(
        $agents_id
    ))) {

        Header("Location:agents.php??durum=ok&agents_id=$agents_id");

    } else {

        Header("Location:agents.php??durum=no&agents_id=$agents_id");
    }
}

?>

Answer this questsion