Forum Moderators: coopster

Message Too Old, No Replies

Using BASE URL of referer without URI properties/values

URI properties/values being?property=value

         

JAB Creations

7:25 pm on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I currently have a weird problem and I know the solution I need though I'm not sure exactly how to execute it.

I'm using an AJAX script to load XHTML includes in to hidden layers that the user might request. However the script breaks. Upon further investigation Gecko reported the following URL error...

index.php?audio=2&connection=1?audio=2

Inside the XHTML includes used in the AJAX I execute PHP at the server which works just fine by default. However when someone initially visits my page they are required to make a choice which is passed through the URL as URI property/values.

Inside the XHTML AJAX includes I use the following code to make sure each prompt is dynamic to the page that requested it...

<a href="<?php echo $_SERVER['HTTP_REFERER'];?>?browserpatch=1" title="">Enable Browser Patching</a>

Because the referer already includes URI properties and values I need to strip away anything past the file extension. I tried base as so...

<a href="<?php echo basename($_SERVER['HTTP_REFERER']);?>?audio=0" title="">Disable Audio</a>

...though the URI property and values remain intact (as not desired) thus breaking the AJAX includes. How can I easily and quickly strip anything past the .php file extension? Is there something like base for this specifically?

- John

mcibor

8:53 pm on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your string is now:
$str = "index.php?audio=2&connection=1?audio=2";

To get everything up to .php you need:

if(($pos = strpos($var,"?")) === false) $new_str = $str;
else $new_str = substr($str, $pos);

This should remove everything starting from "?".

hope this helps
michal