i want to delete the record in mysql database by just clicking on a link but i am unable to accomplish it, i am unable to understand the error. Here is my code
HTML
<a href="processCategory.php?action=delete?id=(<?php echo $id; ?>);">Delete</a>
processCategory.php
<?php
require_once '../library/config.php';
require_once '../library/functions.php';
checkUser();
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'add' :
addCategory();
break;
case 'delete' :
deleteCategory();
break;
default :
// if action is not defined or unknown
// move to main category page
header('Location: index.php');
}
function deleteCategory()
{
if (isset($_GET['id']) && (int)$_GET['id'] > 0) {
$id = (int)$_GET['id'];
} else {
header('Location: index.php');
}
// delete the products
$sql = "DELETE FROM tbl_vendors
WHERE id = $id";
dbQuery($sql);
header('Location: ../vendor');
}
?>