We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,682 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

2
Contributors
1
Reply
1 Hour
Discussion Span
1 Year Ago
Last Updated
2
Views
Farhad.idrees
Junior Poster
102 posts since Dec 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 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
Keep Smiling
Moderator
10,613 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0573 seconds using 2.67MB