Page Redirection in PHP & JavaScript

Today, I was fixing a website which has some issues with page redirection in php.

Filename: donate_us.php

header(“Location: donate.php”);

There is no issues on the code.
But still I got these error.

Warning: Cannot modify header information – headers already sent by (output started at /home/htdocs/site/donate_us.php:1) in /home/htdocs/site/donate_us.php on line 3

Searched internet for a fix.

All are telling to remove any space before <?php and after ?>
There is no space there.

While breaking head for a solution, suddenly, thought of alternate ways to implement the page redirection.

Here, comes the JavaScript redirection.

Filename: donate_us.php

<script type=”text/javascript”>

And, it works fine 🙂

Lesson learned
: Think towards the solution. Dont stuck with current problem.


3 thoughts on “Page Redirection in PHP & JavaScript

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s