hlstriker Posted April 9, 2007 Share Posted April 9, 2007 Hi, I am trying to find the pages url then see if it contains a certain string. Here is the code I used but doesn't work. <? $link = $_SERVER["PHP_SELF"]; $exp = explode("=", $link); $linkname = $exp[0]; $linknumber = $exp[1]; if($linkname == "/viewpage.php?page_id") { echo $linkname; echo $linknumber; } ?> What I'm trying to do is see if "$_SERVER["PHP_SELF"]" contains a certain page. If it contains "/viewpage.php?page_id" I want it to go into that if statement. The problem is it doesn't Btw I need it to explode it because I need the page id number in the other variable for something later. Also another problem is if the link doesn't contain the "=" sign to explode. Would that cause a problem? Link to comment https://forums.phpfreaks.com/topic/46300-check-link-page-url/ Share on other sites More sharing options...
Wildbug Posted April 9, 2007 Share Posted April 9, 2007 For debugging purposes, why don't you try printing the values of $linkname and $linknumber before you get to the "if" block? Link to comment https://forums.phpfreaks.com/topic/46300-check-link-page-url/#findComment-225255 Share on other sites More sharing options...
hlstriker Posted April 9, 2007 Author Share Posted April 9, 2007 Already checked that and it works. Now I just need to know if the explode will work on a page without a = sign. or will that cause errors? Link to comment https://forums.phpfreaks.com/topic/46300-check-link-page-url/#findComment-225319 Share on other sites More sharing options...
hlstriker Posted April 9, 2007 Author Share Posted April 9, 2007 Already checked that and it works. Now I just need to know if the explode will work on a page without a = sign. or will that cause errors? Also I found out the "$link = $_SERVER["PHP_SELF"];" only will contain "/viewpage.php" I need it to also get the "?page_id=x" part that comes after "/viewpage.php". how can I do this? Thanks Link to comment https://forums.phpfreaks.com/topic/46300-check-link-page-url/#findComment-225333 Share on other sites More sharing options...
Caesar Posted April 9, 2007 Share Posted April 9, 2007 <?php $_SERVER['REQUEST_URI']; ?> Link to comment https://forums.phpfreaks.com/topic/46300-check-link-page-url/#findComment-225337 Share on other sites More sharing options...
hlstriker Posted April 9, 2007 Author Share Posted April 9, 2007 Thank you very much Problem is fixed! Link to comment https://forums.phpfreaks.com/topic/46300-check-link-page-url/#findComment-225347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.