This question is an exact duplicate of:
Im trying to do a pop up which says("are you sure you want to delele?") and have OK - CANCEL options..
Here is my delete button:
<a href='borrar.php?borrar=1&iden=".$row['id']."'><button type='button' class='btn btn-danger'>BORRAR</button></a>
And here is the function "delete"
<?php include('connect.php');
$error="";
if(isset($_GET['borrar']))
{
$ident=$_GET['iden'];
$delete=mysql_query("DELETE FROM materias WHERE id=$ident");
if($delete)
header("location:hola.php");
else
$msg='ERROR : '.mysql_error();
}
?>
I wanna make a pop up using bootstraps and i have no idea :/.
Hope you can help me :)
Thanks!
</div>
You can do it by ajax also by following this code :
function deleteRecord(user_id)
{
if(confirm('Sure To Remove This Record ?'))
{
$.ajax({
type: 'POST',
url: 'delete page name',
data: {user_id: user_id},
dataType: "text",
success: function (data)
{
location.reload();
},
error: function(error)
{
}
});
}
}
In html call function like this :
<button onclick="deleteRecord(<?php echo $user_id ?>);" type="submit" class="btn btn-warning btn-xs"><i class="fa fa-power-off" aria-hidden="true"></i></button>
A simple javascript code is
<a href='borrar.php?borrar=1&iden=".$row['id']."' onclick="return confirm('are you sure you want to delele?')"><button type='button' class='btn btn-danger'>BORRAR</button></a>