Jump to content

Check link page url


hlstriker

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.