Return current page and variables: $PHP_SELF dose not do it.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Seth

    #1

    Return current page and variables: $PHP_SELF dose not do it.

    If my current page is:

    $PHP_SELF returns:
    index.php
    What function can I use to return:
    index.php?menu= man&pageid=mfrs/register

    Thanks for your help.
    Seth

  • Henrik Hansen

    #2
    Re: Return current page and variables: $PHP_SELF dose not do it.

    "Seth" <seth7f@gmail.c om> writes:
    [color=blue]
    > If my current page is:
    > https://www.domainname.com/index.php...=mfrs/register
    > $PHP_SELF returns:
    > index.php
    > What function can I use to return:
    > index.php?menu= man&pageid=mfrs/register[/color]

    I think you want $_SERVER["PHP_SELF"] . $_SERVER["QUERY_STRI NG"]

    you can see them all if you do a phpinfo();

    --
    Henrik Hansen

    Comment

    • strawberry

      #3
      Re: Return current page and variables: $PHP_SELF dose not do it.

      Hang on, what about '$PHP_SELF?menu =man&pageid=mfr s/register' ?

      Henrik Hansen wrote:[color=blue]
      > "Seth" <seth7f@gmail.c om> writes:
      >[color=green]
      > > If my current page is:
      > > https://www.domainname.com/index.php...=mfrs/register
      > > $PHP_SELF returns:
      > > index.php
      > > What function can I use to return:
      > > index.php?menu= man&pageid=mfrs/register[/color]
      >
      > I think you want $_SERVER["PHP_SELF"] . $_SERVER["QUERY_STRI NG"]
      >
      > you can see them all if you do a phpinfo();
      >
      > --
      > Henrik Hansen[/color]

      Comment

      • BKDotCom

        #4
        Re: Return current page and variables: $PHP_SELF dose not do it.


        strawberry wrote:[color=blue]
        > Hang on, what about '$PHP_SELF?menu =man&pageid=mfr s/register' ?[/color]

        That will return '$PHP_SELF?menu =man&pageid=mfr s/register'

        try $PHP_SELF.'?men u=man&pageid=mf rs/register'
        or "$PHP_SELF?menu =man&pageid=mfr s/register"

        Comment

        • the DtTvB

          #5
          Re: Return current page and variables: $PHP_SELF dose not do it.

          Henrik Hansen wrote:[color=blue]
          > I think you want $_SERVER["PHP_SELF"] . $_SERVER["QUERY_STRI NG"][/color]

          I use $_SERVER["PHP_SELF"] . ($_SERVER["QUERY_STRI NG"] != '' ? '?' .
          $_SERVER["QUERY_STRI NG"] : '')

          Comment

          • Henrik Hansen

            #6
            Re: Return current page and variables: $PHP_SELF dose not do it.

            "strawberry " <zac.carey@gmai l.com> writes:
            [color=blue]
            > Hang on, what about '$PHP_SELF?menu =man&pageid=mfr s/register' ?
            >[/color]

            thats hardcoded, I think he want to use a dynamic solution, if ex. the
            url changes etc. And why hardcode it when you got all the info in the
            server array.

            --
            Henrik Hansen

            Comment

            • Henrik Hansen

              #7
              Re: Return current page and variables: $PHP_SELF dose not do it.

              "the DtTvB" <mechakoopa@gma il.com> writes:
              [color=blue]
              > Henrik Hansen wrote:[color=green]
              >> I think you want $_SERVER["PHP_SELF"] . $_SERVER["QUERY_STRI NG"][/color]
              >
              > I use $_SERVER["PHP_SELF"] . ($_SERVER["QUERY_STRI NG"] != '' ? '?' .
              > $_SERVER["QUERY_STRI NG"] : '')
              >[/color]

              Right, thats probably more correct, if the query string is empty at times ..

              --
              Henrik Hansen

              Comment

              • strawberry

                #8
                Re: Return current page and variables: $PHP_SELF dose not do it.

                sorry about the inverted commas. I meant by them to say use the text
                within them.

                As for a dynamic solution - substitute 'man' with $man or {$row['man']}
                or whatever and you've got a dynamic solution.

                No doubt, the other method provided is more correct and more dynamic I
                just thought the OP might appreciate the simplicity of this solution -
                at least in terms of implementation relative to what they had already.
                Actually I'll use the SERVER method myself once I figure out how to
                implement it! Until then the method I describe works just fine for me.

                Cheers,

                Henrik Hansen wrote:[color=blue]
                > "strawberry " <zac.carey@gmai l.com> writes:
                >[color=green]
                > > Hang on, what about '$PHP_SELF?menu =man&pageid=mfr s/register' ?
                > >[/color]
                >
                > thats hardcoded, I think he want to use a dynamic solution, if ex. the
                > url changes etc. And why hardcode it when you got all the info in the
                > server array.
                >
                > --
                > Henrik Hansen[/color]

                Comment

                • melb00m@gmail.com

                  #9
                  Re: Return current page and variables: $PHP_SELF dose not do it.

                  I´d also suggest the $_SERVER['QUERY_STRING'] solution. But if that´s
                  something you need on every page of your website, maybe a session with
                  those variables would be the better solution.

                  Comment

                  • Karl Groves

                    #10
                    Re: Return current page and variables: $PHP_SELF dose not do it.

                    Henrik Hansen <spam@fsck.dk > wrote in news:87hd2ulrk4 .fsf@fsck.dk:
                    [color=blue]
                    > "the DtTvB" <mechakoopa@gma il.com> writes:
                    >[color=green]
                    >> Henrik Hansen wrote:[color=darkred]
                    >>> I think you want $_SERVER["PHP_SELF"] . $_SERVER["QUERY_STRI NG"][/color]
                    >>
                    >> I use $_SERVER["PHP_SELF"] . ($_SERVER["QUERY_STRI NG"] != '' ? '?' .
                    >> $_SERVER["QUERY_STRI NG"] : '')
                    >>[/color]
                    >
                    > Right, thats probably more correct, if the query string is empty at
                    > times ..
                    >[/color]


                    Is the above method better or worse than $_SERVER['REQUEST_URI'];


                    --
                    Karl Groves

                    Comment

                    • John Dunlop

                      #11
                      Re: Return current page and variables: $PHP_SELF dose not do it.

                      Karl Groves:
                      [color=blue]
                      > Is the above method better or worse than $_SERVER['REQUEST_URI'];[/color]

                      If you want to grab part of the URL, I'd use your REQUEST_URI or
                      QUERY_STRING, since PHP_SELF corresponds to the URL by coincidence
                      only.

                      --
                      Jock

                      Comment

                      Working...