hi am using the below shown code for getting index.php of www.test.com/index.php session_start(); $pagename=pathinfo($_SERVER["PHP_SELF"]); $pagename=$pagename["basename"]; $_SESSION['page']=$pagename; PHP: $_SESSION['page'] has the value index.php ie if i am on www.test.com/abc.php $_SESSION['page'] has the value abc.php it is working fine.. but my problem is that.. if the url is www.test.com/index.php?catid=60 the rest part after index.php ie '?catid=60' is not retrieved.. how can i do that??? please help.. i will be very grateful.. thank you
If I'm not mistaking it is basename which only takes the actual page and not the parameters You could do this: $url = $_SERVER["PHP_SELF"]; $page = split("/", $url); //returns an array, we need last item of it $length = count($page); $_SESSION['page'] = $page[$length-1]; Code (markup):
Think this has to do with a bug of PHP_SELF not working right on older versions of Apache. Maybe try using $_SERVER['REQUEST_URI'] instead.
If you know catid is always going to be the only parameter, you might do this: session_start(); $pagename=pathinfo($_SERVER["PHP_SELF"]); $pagename=$pagename["basename"]; if (isset($_GET['catid'])) {$pagename .= '?catid='.$_GET['catid'];} $_SESSION['page']=$pagename;
JDevereux , thanks a lot . tried wat u said.. it worked.. thanks once again.. Thanks to all the others who gave suggestions . Really appreciate your willingness to help.. thank u.......