PHP question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zester
    Confirmed User
    • Jul 2003
    • 5344

    #1

    PHP question

    is there a way in a php script to detect if it was called with this url:
    http://domain.com/myscript.php#12

    or this:
    http://domain.com/myscript.php

    some kind of server variable I don't know of?
    * Mainstream ? $65 per sale
    * new male contraception
  • arnette
    Confirmed User
    • Feb 2005
    • 283

    #2
    nope, those pages are considered one and the same with php.
    it could probably be done with a php/javascript combo

    Comment

    • StuartD
      Sofa King Band
      • Jul 2002
      • 29903

      #3
      $_SERVER[HTTP_HOST]
      This is me on facebook
      This is me on twitter

      Comment

      • Fetish Gimp
        Confirmed User
        • Feb 2005
        • 1699

        #4
        Is the php script you're talking about running on the same server? Cuz depending on the situation you can use the $_SERVER['REFERER'] or $_SERVER['SCRIPT_FILENAME']. Here's more about the server variables
        http://ca3.php.net/reserved.variables
        Strapon Seduction - femdom blog | Twitter

        Comment

        • AcidMax
          Confirmed User
          • May 2002
          • 1827

          #5
          You could probably use a preg_match to look at the url and see if its being called that way.

          Andy
          Latest MMA news. http://www.mmawrapup.com

          Comment

          • Serge Litehead
            Confirmed User
            • Dec 2002
            • 5190

            #6
            Code:
            if (isset($_SERVER['HTTP_REFERER']))
            {
            	if (strpos($_SERVER['HTTP_REFERER'],"domain.com/myscript.php") !hahahaha false)
            	{
            		echo "this script called with domain.com/myscript.php";
            	}
            	else
            	{
            		echo "call by ".$_SERVER['HTTP_REFERER'];
            	}
            }
            else 
            {
            	echo "no referer";	
            }
            replace hahahaa with double equal signs (=)

            Comment

            • Serge Litehead
              Confirmed User
              • Dec 2002
              • 5190

              #7
              regarding previous post
              that code will work only if myscript.php is linking to the php file this code is on.
              if its not the case then more info needed how is current script beign called by myscript.php

              Comment

              • Zester
                Confirmed User
                • Jul 2003
                • 5344

                #8
                i tried every server variable, everything in $_SERVER , the #12 is mentioned no where.
                referer is not set - it is a bookmark
                * Mainstream ? $65 per sale
                * new male contraception

                Comment

                • Zester
                  Confirmed User
                  • Jul 2003
                  • 5344

                  #9
                  Originally posted by arnette
                  nope, those pages are considered one and the same with php.
                  it could probably be done with a php/javascript combo
                  yes, i have no problem detecting it in javascript, but in order to use a combo with PHP, i have to use either a cookie or post or get to that same page which i want to avoid

                  and as far as i know and tried you can not pass a javascript var to a php var - only the other way around
                  * Mainstream ? $65 per sale
                  * new male contraception

                  Comment

                  • Serge Litehead
                    Confirmed User
                    • Dec 2002
                    • 5190

                    #10
                    Originally posted by Zester
                    i tried every server variable, everything in $_SERVER , the #12 is mentioned no where.
                    referer is not set - it is a bookmark
                    unless you going to your script from myscript.php you wont see the referer
                    may need to check your apache logs to see if there were any referer from that particular location, or write your own log

                    Comment

                    Working...