Hei, is there someone there?????? 😕

I have this line bellow in my script, but the program don´t stop!
Where i´am wrong?
if you click in "Cancel" button, the data should be deleted like if you pressed "Ok" how can i resolv this?

print
"<script language=javascript>
if (window.confirm('$msg') == false ){
window.parent.location='set.page.php?$param';
document.execCommand('Stop');
}
</script>";
stop("ok");
die;
//Mount delete query according each table field types situation
$query="DELETE FROM $table WHERE $where";
$result=mysql_query($query) or die("Erro de exclusão! Contate seu webmaster (#27)");
parent_location("set.page.php?$param");

    Your problem here is that PHP runs all the php code and then outputs to a broswer in html/text format. which means any php code will be executed befor the browser even recieves the javascript.

    create a js yes/no msg box, if yes, use js header command to redirect to another php page where the php code can be executed. If no then, js to go to the browser back page.

    PS, this is a PHP forum and we don't deal with javascript. What i just told you is based of limited knowledge.

      To stop a script in its tracks, just use

      exit;

        Hi friend,
        Firstly thanks for your help... but try you self to do your sugestion running the code bellow... incredible the PHP don´t stop..
        If you find another solution i´ll thank very much!

        <?php
        $permited=true;
        if ($permited){
        print
        "<script language=javascript>
        if (window.confirm('Try to stop now?')){
        alert('ok.. stop');
        exit;
        }
        </script>";
        }
        stop("Stop Fail!");
        ?>

          You're printing the exit out to the browser, not running the function

            <?php
            
            $permitted=true;
            if ($permitted)
            {
            
            die("AHAHA IT STOPPED");
            
            }
            
            ?>

            ....lol

              This also works:

              <?php
              
              if($condition == true) exit;
              
              ?>
              

                you forgot the { and } around exit; but it would work

                  I see what you are doing, Javascript. My bad.

                  Well, if your code was all PHP, exit() is the escape function but in javascript, break and return false is the escape.
                  Unfortunatly, you can not escape your method because the page needs to render all to complete the javascript code. Use items such as the example below if this envolves a sql insert, update or delete.

                  if (isset($_POST['submit'])) {
                      if (empty($_POST['username'])) {
                          header("location: whatever.php?error=1"); exit;
                      } else {
                          // process
                      }
                  } else {
                      if ($_GET['error']==1) { echo "Sorry, you need to enter the username\n"; }
                      // page stuff here
                  }

                  Javascript escapes as follows

                  <script type="text/javascript">
                      function validate_form(form) {
                          if (form.field1.value == "" || form.field2.value == "") {
                              alert('All field are required    ');
                              return false;
                          } else {
                              return true;
                          }
                      }
                  </script>
                    TenFold wrote:

                    you forgot the { and } around exit; but it would work

                    It's a shortcut. You only need those braces when there's more than one line. I never use them for short lines like this.

                      Thanks for every sugestions... i´ll try later... tomorrow i´ll resent answers!

                        Ludichrist wrote:

                        It's a shortcut. You only need those braces when there's more than one line. I never use them for short lines like this.

                        oh, well, I do 😃

                          a month later

                          Hi friends,
                          Someone there knows some method to Request my form variables from my page 1 in page-2 without to use $HTTP_POST_VARS? But why? Because i´ve got aproximadetly hundred fields to get and i will have a great work to do if i always needed to write one by one of this command.

                          thanks for all

                            TenFold wrote:

                            oh, well, I do 😃

                            Really thanks!

                              When I submit form with taget="_parent" the scrollbars are hidding from the window...
                              How can I recompose the scrollbars a time that my table list out of window sizes?
                              Thanks

                                paulomaia wrote:

                                Hi friends,
                                Someone there knows some method to Request my form variables from my page 1 in page-2 without to use $HTTP_POST_VARS? But why? Because i´ve got aproximadetly hundred fields to get and i will have a great work to do if i always needed to write one by one of this command.

                                thanks for all

                                First point is you should be using $_POST rather than $HTTP_POST_VARS these days.

                                It is not regarded as good practice, because there are the same security issues as there are when register_globals is turned on, but you might want to use the following for your 100 or so variables on page 2, which will extract all of the elements of the array $_POST in one go.

                                extract($_POST);

                                This will give you access to the variables by their variable name on page 2.

                                Blu

                                  Write a Reply...