returning session, Parse URL, Return and redirect
Posted: Thu Feb 05, 2009 7:02 pm
My goal is to have the pid change every time the user returns and redirect to appropriate next page on the site. So in essence if I leave the site and come back I go from pg1.php to pg2.php..
code follows..
<?php
session_start();
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
//$link = "http://www.ikyp.com/pharma/tutorial/214";
$link = curPageURL();
$digit = explode("http://www.ikyp.com/pharma/tutorial/",$link);
$_SESSION["pid"] = $digit[1];
?>
<?php
session_start();
if (isset($_SESSION['pid'])) {
if ($_SESSION['pid'] == "214") {
header ("Location: 1A.php");
}
else if ($_SESSION['pid'] == "215") {
header ("Location: 1B.php");
}
else if ($_SESSION['pid'] == "216") {
header ("Location: 2.php");
}
else if ($_SESSION['pid'] == "217") {
header ("Location: 3.php");
}
else if ($_SESSION['pid'] == "218") {
header ("Location: 4A.php");
}
else if ($_SESSION['pid'] == "219") {
header ("Location: 4B.php");
}
else if ($_SESSION['pid'] == "220") {
header ("Location: 4C.php");
}
else if ($_SESSION['pid'] == "221") {
header ("Location: 5A.php");
}
else if ($_SESSION['pid'] == "222") {
header ("Location: 5B.php");
}
else if ($_SESSION['pid'] == "223") {
header ("Location: 5C.php");
}
else if ($_SESSION['pid'] == "224") {
header ("Location: 5D.php");
}
else if ($_SESSION['pid'] == "225") {
header ("Location: 6A.php");
}
else if ($_SESSION['pid'] == "226") {
header ("Location: 6B.php");
}
else if ($_SESSION['pid'] == "227") {
header ("Location: 6C.php");
}
else if ($_SESSION['pid'] == "228") {
header ("Location: 7A.php");
}
else if ($_SESSION['pid'] == "229") {
header ("Location: 7B.php");
}
else if ($_SESSION['pid'] == "230") {
header ("Location: 7C.php");
}
else if ($_SESSION['pid'] == "231") {
header ("Location: 8A.php");
}
else if ($_SESSION['pid'] == "232") {
header ("Location: 8B.php");
}
else if ($_SESSION['pid'] == "233") {
header ("Location: 8C.php");
}
else if ($_SESSION['pid'] == "234") {
header ("Location: 9A.php");
}
else if ($_SESSION['pid'] == "235") {
header ("Location: 9B.php");
}
else if ($_SESSION['pid'] == "236") {
header ("Location: 10A.php");
}
else if ($_SESSION['pid'] == "237") {
header ("Location: 10B.php");
}
else if ($_SESSION['pid'] == "238") {
header ("Location: 11A.php");
}
else if ($_SESSION['pid'] == "239") {
header ("Location: 11B.php");
}
else if ($_SESSION['pid'] == "240") {
header ("Location: 11C.php");
}
else if ($_SESSION['pid'] == "241") {
header ("Location: 11D.php");
}
else if ($_SESSION['pid'] == "242") {
header ("Location: 12A.php");
}
else if ($_SESSION['pid'] == "243") {
header ("Location: 12B.php");
}
else {
header ("Location: 1B.php");
}
}
else {
echo "Session var is not set!";
}
session_start();
session_unregister("pid");
session_destroy();
?>
Any help would be greatly appreciated..
code follows..
<?php
session_start();
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
//$link = "http://www.ikyp.com/pharma/tutorial/214";
$link = curPageURL();
$digit = explode("http://www.ikyp.com/pharma/tutorial/",$link);
$_SESSION["pid"] = $digit[1];
?>
<?php
session_start();
if (isset($_SESSION['pid'])) {
if ($_SESSION['pid'] == "214") {
header ("Location: 1A.php");
}
else if ($_SESSION['pid'] == "215") {
header ("Location: 1B.php");
}
else if ($_SESSION['pid'] == "216") {
header ("Location: 2.php");
}
else if ($_SESSION['pid'] == "217") {
header ("Location: 3.php");
}
else if ($_SESSION['pid'] == "218") {
header ("Location: 4A.php");
}
else if ($_SESSION['pid'] == "219") {
header ("Location: 4B.php");
}
else if ($_SESSION['pid'] == "220") {
header ("Location: 4C.php");
}
else if ($_SESSION['pid'] == "221") {
header ("Location: 5A.php");
}
else if ($_SESSION['pid'] == "222") {
header ("Location: 5B.php");
}
else if ($_SESSION['pid'] == "223") {
header ("Location: 5C.php");
}
else if ($_SESSION['pid'] == "224") {
header ("Location: 5D.php");
}
else if ($_SESSION['pid'] == "225") {
header ("Location: 6A.php");
}
else if ($_SESSION['pid'] == "226") {
header ("Location: 6B.php");
}
else if ($_SESSION['pid'] == "227") {
header ("Location: 6C.php");
}
else if ($_SESSION['pid'] == "228") {
header ("Location: 7A.php");
}
else if ($_SESSION['pid'] == "229") {
header ("Location: 7B.php");
}
else if ($_SESSION['pid'] == "230") {
header ("Location: 7C.php");
}
else if ($_SESSION['pid'] == "231") {
header ("Location: 8A.php");
}
else if ($_SESSION['pid'] == "232") {
header ("Location: 8B.php");
}
else if ($_SESSION['pid'] == "233") {
header ("Location: 8C.php");
}
else if ($_SESSION['pid'] == "234") {
header ("Location: 9A.php");
}
else if ($_SESSION['pid'] == "235") {
header ("Location: 9B.php");
}
else if ($_SESSION['pid'] == "236") {
header ("Location: 10A.php");
}
else if ($_SESSION['pid'] == "237") {
header ("Location: 10B.php");
}
else if ($_SESSION['pid'] == "238") {
header ("Location: 11A.php");
}
else if ($_SESSION['pid'] == "239") {
header ("Location: 11B.php");
}
else if ($_SESSION['pid'] == "240") {
header ("Location: 11C.php");
}
else if ($_SESSION['pid'] == "241") {
header ("Location: 11D.php");
}
else if ($_SESSION['pid'] == "242") {
header ("Location: 12A.php");
}
else if ($_SESSION['pid'] == "243") {
header ("Location: 12B.php");
}
else {
header ("Location: 1B.php");
}
}
else {
echo "Session var is not set!";
}
session_start();
session_unregister("pid");
session_destroy();
?>
Any help would be greatly appreciated..