Jump to content

Confirm Message Box


yash87

Recommended Posts

Can anyone help me with this delete confirm box. I have tried but somehow its not working. Can anyone help me with this?

 

Thankz.

 

html codes :

 

echo "<td><a href=delete.php?id=" . $rows['id'] ." onclick=\"return confirm(Are you sure?);\">Delete</a></td>";

 

delete.php :

 

<?php
include "config.php";
?>

<?php
$id=$_GET['id'];
?>

<script type="text/javascript">
<!--
function confirmation() {
    var answer = confirm('Are you sure you want to delete?')
    if (answer){
        $sql="DELETE FROM document WHERE id='$id'";
    }
    else{
        alert("Cancelled the delete!")
    }
}

</script> 

 

Link to comment
https://forums.phpfreaks.com/topic/216869-confirm-message-box/
Share on other sites

Dude,

 

I guess u need to change your logic as follows:

 

In first file, separate JS code -

 

<script type="text/javascript">

function call_confirm(){

var answer = window.confirm ("Are you sure you want to delete?");

if (answer)

return true;

else

return false;

}

</script>

 

<?php

 

echo "<td><a href=delete.php?id=" . $rows['id'] ." onclick=\"return call_confirm()\">Delete</a></td>";

 

?>

 

In your delete.php, directly write query.

 

$id=$_GET['id'];

$sql="DELETE FROM document WHERE id='$id'";

Link to comment
https://forums.phpfreaks.com/topic/216869-confirm-message-box/#findComment-1126604
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.