How would I integrate a javascript alert window with an alert message on die? I want the code that's on the page to remain and have the alert box appear with a message I choose. It seems that on die I can get a message but it kills the code below. Want everything on the page to remain stable, but just have the alert window popup on error.

if(!$_POST['username'] | !$_POST['password']) {
die('You Must Enter in a Username and Pass');
}
    die('<script type="text/javascript">
    alert("nice try");
    </script>
    Some other useful text');

      Okay, well it works, .......but the page behind the popup window is cut off and dies.

      What i'd really love to do is keep the page content and display the alert window over top. Anyway this is possible???

      Thanks

        2 years later

        echo will not work, here is the correct way to stay on the page or be redirected to another page called new_page.php

        or die('<script type="text/javascript">alert("nice try");location.replace("new_page.php")</script>');

          Write a Reply...