Java script alert with header problem
Hi...
i m making script which is checking that username aur password is true or not.....
i want to show alert if username or password is incorrect.then i want to redirect my page to original login page....
my code is
$alert = "<script type=\"text/javascript\">alert('Invalid UserName or Password');</script>";
echo $alert;
header("Location:../Admin.php");
the problem is alert is not showing and suddenly i m redirect to my original page...
what should i do?
Regards.....
Farhad
Farhad.idrees
Junior Poster in Training
63 posts since Dec 2010
Reputation Points: 11
Solved Threads: 0
The js is run on the client, so it won't show until the page has finished loading. BUT, you're stopping the page load with a redirect.
You could use a delayed redirect:
<body>
<?php
header('Refresh: 3; url=index.html');?>
<p>hello</p>
</body>
Either that or use a javascript redirect after the alert.
diafol
Rhod Gilbert Fan (ardav)
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080