-5

In this code, the alert box is not working. I want to redirect page and show a message using alertbox. How can I fix it?

 if($stmt){ 
?>
    <script type="text/javascript">
        alert("Package Successfully Booked..");
    </script>
<?php
header("location:javascript://history.go(-1)");
}
?>  
Rasclatt
  • 12,498
  • 3
  • 25
  • 33
Pavel
  • 1
  • 3
  • Then put the history.go call after the alert, rather than trying to put it in the header (which is nonsensical BTW). – Alexander O'Mara Aug 28 '16 at 06:16
  • http://stackoverflow.com/questions/11869662/display-alert-message-and-redirect-after-click-on-accept – soundslikebliss Aug 28 '16 at 06:20
  • here, redirect page is fixed. redirect('admin/ahm/panel'); . but i have no fixed page – Pavel Aug 28 '16 at 06:24
  • 1
    Possible duplicate of [What is the difference between client-side and server-side programming?](http://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – jmattheis Aug 28 '16 at 09:02

1 Answers1

0

You can alert the user using windows load function.

window.onload = function () {
   alert('Package Successfully Booked!');

}

or you can do it this way

<html>
<head>
<script>
function showAlert()
    {
    alert("Package Successfully Booked!");
    }
    </script>
</head>
<body onload="showAlert()">
</body>
</html>
mior farhan
  • 82
  • 10