Sunday 2 October 2016

javascript - Button type=submit with php isset instead of input typebutton




I have been searching this stuff but could not find anywhere.
when i search about button name and value, everywhere its mentioned about input type=button



But i am looking for button type=submit instead of input type=button
i want to allow users to remove their comments. So, the delete button is just showing like a link



The Html is






I am not getting how can i check if this button is clicked or not not using php as i tried



if(isset('delcom'))
{
$sql = "DELETE FROM comments WHERE id = :id";
$stmt = $DB->prepare($sql);
$stmt->bindValue(":id", $comid);
$stmt->execute();
}
?>


But its not working.



Meanwhile, i want a popup alert message that confirms Delete Query includings Delete or Cancel buttons on it



I don't want that simple javascript alert on the top of the page. I want some popup window in the middle of the screen with my own Color scheme



Please help


Answer



Make sure to get it from the POST variable to check. This is probably what you're actually intending on doing.



    if(isset($_POST['delcom']))
{
$sql = "DELETE FROM comments WHERE id = :id";
$stmt = $DB->prepare($sql);
$stmt->bindValue(":id", $comid);
$stmt->execute();
}
?>

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...