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

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.