Skip to content Skip to sidebar Skip to footer

Using _get Url Link To Delete A Record From Mysql Database

EDIT Thanks for the help so far. I have edited my post to reflect the changes suggested below. I am using PDO for my database connection. The code I have now is as follows: HTML &l

Solution 1:

Your HTML section says:

<a href="includes/delete-customer.php?customer_id=$id['.$row->customer_id.']">

Is this your exact HTML syntax? This argument should be the actual numerical id, i.e. --

<ahref="includes/delete-customer.php?customer_id=3">

-- either by echoing $row->customer_id (assuming it exists), or some other method of knowing that user id.

Your HTML only needs to send the actual data, not any sort of variable syntax. Your receiving PHP ($_GET['customer_id']) will interpret that for you and properly pass that to MySQL.

Solution 2:

Your URL passes userID as the get parameter, yet in your php script you're trying to access customer_id. Try changing your code to retrieve userID and it should work

if (isset($_GET['userID']) && is_numeric($_GET['userID']))

Solution 3:

<ahref="includes/delete-customer.php?customer_id=<?phpecho$id[$row->customer_id]; ?>">

assuming $id[$row->customer_id] is valid.

Plus, you really shouldn't delete from database on get var unless you're doing some admin validation / access rules and guarantee you don't have anyone on the job who will go rogue and manually type in numbers there.. That's just plain crazy.

Post a Comment for "Using _get Url Link To Delete A Record From Mysql Database"