Help - Search - Members - Calendar
Full Version: Zymic Does Not Allow Page Redirect?
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
Adonis Lee Villamor
I have pages which do checks and redirects somewhere whenever a condition is met or not. Now in my laptop the pages work fine but if uploaded and hosted i here it does'nt redirect which causes a lot of problems like users accessing pages which they should'nt until a condition was met.

here's a sample:

---------------------------------------------------

<?php
session_start();
if (isset($_SESSION['ID'])
{
$ID= $_SESSION['ID'];
}
else
{
header('location : Index.php');
}
?>

<body>
Hello <?php echo $ID;?>
</body>

----------------------------------------------------------

what happens is in my laptop, it will redirect if I open that page when the session was not set and will greet me if it was set. In the web host however it ignores the redirect causing me to see the page as "Hello [blank]" and never redirects. why is that? is the server's configuration different from my laptop's? is the Header() function disallowed? if so what do we use for server side redirects here?
Adonis Lee Villamor
Found the reason now...
hunter.gif

after some confusing trial and errors, it was found that the host is more sensitive to the way the header function is stated

unlike my desktop/laptop's php, it won't allow calls like
header ('location : Index,php');
header (' location : Index,php ');
header("Location : Index,php");

it only works as
header("Location:Index.php");

no spaces at all... the anoying part of this is it won't say anything like an error on the function call ...
shinjiketojapann
here try this simple function

CODE
function Redirect($time, $topage) {

echo "<meta http-equiv=\"refresh\" content=\"{$time}; url={$topage}\" /> ";

}


then to call the redirect you use

4 being how long it takes to be redirected,
in milliseconds, if i recall correct,
foo.php,being the page to be redirected to.

CODE
Redirect(4, "foo.php");


this is of course a vary simple edit to the header problem

you could make a simple functions.php file to store this and other functions
swordz
If you're just redirecting, with no output displayed, use the header() function as you are - it's much faster.

swordz
NDBoost
QUOTE(swordz @ Jan 31 2009, 12:53 AM) *
If you're just redirecting, with no output displayed, use the header() function as you are - it's much faster.

swordz


x2, i hate meta redirects theyre "Sloppy"
Andrew
Though they can be useful in some occasions, IPB using them must say something tongue.gif
NDBoost
They use them because i'm sure theyre already sending headers and making it pretty difficult to use header: that way.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.