-
May 9th, 2014, 11:30 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Error When Redirecting a Page
Hi,
I am developing a login system. I want that if user provide correct info, the page redirects to welcome.php , but its giving an error "Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\MyWork\LoginDemo.php:18) in C:\xampp\htdocs\MyWork\LoginDemo.php on line 33"
my code is as under
Code:
if ($count >= 1) {
echo "My User Name : " . $username . "<br/>";
echo "My password : " . $password;
header('Location: WelcomePage.php'); /* Redirect browser */
} else {
echo "Invalid User";
}
** line 33 is header('Location: WelcomePage.php'); /* Redirect browser */
-
May 10th, 2014, 01:06 AM
#2
Re: Error When Redirecting a Page
What browser are you using? Have you tried different browsers? I also experienced same error before and my solution I think was to use JavaScript to move to another location.
-
May 10th, 2014, 01:12 AM
#3
Thread Starter
Fanatic Member
Re: Error When Redirecting a Page
Thanks for the reply,
I am using FireFox, issue is that if i create a new PHP file and write the same code for redirection, it works. It is just showing error within this project
-
May 10th, 2014, 03:49 AM
#4
Re: Error When Redirecting a Page
What is on line 18 of your code?
You are either using "echo" or you close and open your php tags...
There should be no HTML output prior to a header.
-
May 10th, 2014, 04:33 AM
#5
Thread Starter
Fanatic Member
Re: Error When Redirecting a Page
On line 18, there was an If Statement, i deleted it.
There were few other HTML commands like <br> , <hr> etc before HEADER, delete all. Now its working fine
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|