First I have to show alert box then I have to transfer to another.But in my case it is not showing alert box and it is going to another page.
echo "<script>alert('Your Record Sucessfully Inserted.Now Login');</script>";
header('location:login.php');
For achive this functionality you can do as below
echo "<script>if(confirm('Your Record Sucessfully Inserted. Now Login')){document.location.href='index.php'};</script>";
For this, you simply need to add some extra JavaScript after the alert.
echo "<script>alert('Your Record Sucessfully Inserted.Now Login');window.location.href = 'www.example.com';</script>";
Change www.example.com
to whatever page you want to redirect to.
The window.location.href = 'www.example.com';
is what redirects the user and won't run until the alert box is closed.
Here is function that shows alert and then redirect you to another url:
function myAlert($msg, $url){
echo '<script language="javascript">alert("'.$msg.'");</script>';
echo "<script>document.location = '$url'</script>";
}
myAlert("Your Record Sucessfully Inserted.Now Login", "login.php");