Page Redirection in PHP & JavaScript

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

Filename: donate_us.php


<?php
error_reporting(E_ALL);
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

<head>
<script type=”text/javascript”>
<!–
   window.location=”http://<site-name>/donate.php&#8221;;
//–>
</script>
</head>

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s