...

View Full Version : Help with redirecting a page using if and else possibly



mobimad
03-16-2010, 11:54 PM
Hi,
I've been trying to redirect to 2 different pages based on a variable within the url.

Basically

if $site=site1 redirect to this page with the following parameters
if $site=site2 redirect to this page with the following parameters

i've tried every tutorial and even tried the switch, but with no luck.

Please could somebody show what i'm doing wrong

Heres the code
Thanks in-advance
Jenna




<?php
$site=$_GET['site'];

if($site == 'site1') {

$host = $_SERVER['HTTP_HOST'];
$extra = 'downloadsite1.php?';
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$unencodedP = urldecode(stripslashes($_REQUEST['p']));
$costP = ($_REQUEST['c']);
$userP = ($_REQUEST['u']);
$networkP = ($_REQUEST['n']);
$regionP = ($_REQUEST['r']);
header("Location: http://$host$uri/$extra$unencodedP&n=$networkP&u=$userP&r=$regionP&c=$costP");

}

if($site == 'site2') {

$host = $_SERVER['HTTP_HOST'];
$extra = 'downloadsite2.php?';
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$unencodedP = urldecode(stripslashes($_REQUEST['p']));
$costP = ($_REQUEST['c']);
$userP = ($_REQUEST['u']);
$networkP = ($_REQUEST['n']);
$regionP = ($_REQUEST['r']);
header("Location: http://$host$uri/$extra$unencodedP&n=$networkP&u=$userP&r=$regionP&c=$costP");

}

exit;
?>

tomws
03-17-2010, 01:19 AM
You explained what you want, but you didn't explain what problem you're having.

mobimad
03-17-2010, 12:08 PM
The Problem i am having is that it is not re-directing to the correct page if site=site1 or if site=site2,

just get a blank page.
Jenna

tomws
03-17-2010, 02:30 PM
A blank page usually means there's a parse error or syntax error in the code and your error reporting is turned off, so you can't see it. Search the forum for "php error reporting" to learn how to turn it on. Then post your error.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum