Question

How can I halt a php code block when JS confirm false result. My php code like this;

<?php
function func($msg){
 echo '<script type="text/javascript">
        var r = confirm('$msg');
        if(r==false){
           return false;
        }else{
           return true; 
        }
       </script>';
}

.
.

case "update":
func("Do you want to delete?");
mysql_query("UPDATE.....");
break; 


?>

When func() result is false, dont process mysql_query()

Was it helpful?

Solution

With this approach it can not be done. Javascript and PhP are different things. Javascript executes on client side end but php is server end. You would have to take into Account the power of Ajax. have a look at something similar

How to Delete MySQL Rows with Ajax & jQuery

SIMPLE JQUERY AJAX DELETE WITH CONFIRMATION

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top