Hey troops,
Oh man I am getting so frustated with this issue I have![]()
I have been trying to make a link that will delete an entry to a database. I can get it working with a $_GET method, but I would like to do it via $_POST as I don't want the id number displayed in the url as it would be vulnerable for the others to be deleted too.
Here is what I have at the moment:
in the body:
This is the validation:PHP Code:if(isset($message)) {
echo '<p class="error">', $message,'</p>';
}
$i = 0;
$value = array(2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70);
while ($row = mysql_fetch_array($result)) {
echo "<td>".$row['jobCategoryName']." <a href='".$_SERVER['PHP_SELF']."?jobCategoryId=".$row['jobCategoryId']."'>Delete</a></td>";
$i++;
if (in_array($i,$value)) {
echo "</tr><tr>";
}
}
How do I get it so it doesn't show in the url?PHP Code:if(isset($_GET['jobCategoryId'])) {
@include ('../../signup.php'); # db signup
$jobId = $_GET['jobCategoryId'];
$query = "SELECT jobCategoryName FROM jobCategory WHERE jobCategoryId = '$jobId' LIMIT 1";
$result = mysql_query($query);
if ($result) {
while ($row = mysql_fetch_array($result)) {
$jobName = $row['jobCategoryName'];
}
}
$delete = "DELETE FROM jobCategory WHERE jobCategoryId = '$jobId'";
$resultdelete = mysql_query($delete);
if(!$resultdelete) {
$message .= "That didn't work!";
} else {
$message .= "You have just deleted ".$jobName." from the database.";
}
}
Any help would be so much appreciated!![]()







And happy birthday Dan! 

Bookmarks