Search code examples
javascriptphpjqueryconfirmation

Confirmation box in PHP


I'm trying to popup a confirmation box after the submit button is pressed in if clause. If you click "OK" the PHP script proceeds, if you click "Cancel", it stops.

if(isset($_POST['submit'])) {
   $get_randeman = $_POST['randeman_realize'];
   if($get_randeman < $randeman_min) {
      echo '<script>confirm("Are you sure?");
          if(confirm("Are you sure?") == false) {
             return;
          } else {
          continue;
         }
   </script>';
} else {

//proceed

Solution

  • You need something like this :

    <a href="http://www.google.com" onclick='
                if(confirm("Are you sure?") == false) {
                    return false;
                } else {
                    //
                }'>google.com</a>