Alternatives to $PHPSELF

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

    Alternatives to $PHPSELF

    My boss has saddled me with this task, so I don't know all the
    specifics. What I do know, is that I am looking for something similar
    to this:

    <form action="<? echo $PHPSELF ?>" method="POST">

    Syntax aside, I think you can see what we are trying to accomplish. We
    want to use PHP to call the exact same page that the form is on, for
    processing. I take it that the page with the form will also contain
    some PHP code that is executed when the page is reloaded. We want to
    be able to reload the page, independent of the page name. So that if
    we decide to rename the page foo.php or bar.php, it doesn't matter
    because the form reloads its own page by reference, and not by name.

    Other than $PHPSELF, $PHP_SELF or $SERVER['PHP_SELF'] (that should
    just about cover it), what other options are there? I am looking for
    all possible ways to do this. If you want, please just respond with a
    keyword or a code snippet. I can research the details. Thank you in
    advance.

  • Erwin Moller

    #2
    Re: Alternatives to $PHPSELF

    Jerim79 wrote:
    My boss has saddled me with this task, so I don't know all the
    specifics. What I do know, is that I am looking for something similar
    to this:
    >
    <form action="<? echo $PHPSELF ?>" method="POST">
    >
    Syntax aside, I think you can see what we are trying to accomplish. We
    want to use PHP to call the exact same page that the form is on, for
    processing. I take it that the page with the form will also contain
    some PHP code that is executed when the page is reloaded. We want to
    be able to reload the page, independent of the page name. So that if
    we decide to rename the page foo.php or bar.php, it doesn't matter
    because the form reloads its own page by reference, and not by name.
    >
    Other than $PHPSELF, $PHP_SELF or $SERVER['PHP_SELF'] (that should
    just about cover it), what other options are there? I am looking for
    all possible ways to do this. If you want, please just respond with a
    keyword or a code snippet. I can research the details. Thank you in
    advance.
    Hi Jerim,

    Many browsers reload if the href of a hyperlink or the action in a form is
    empty. I wouldn't trust that behaviour, however...

    But WHY do you not want to use the obvious good solutions you described
    yourself?

    Sounds to me like: I want to fly to Autralia, and I know I can take a plane,
    but what other options do I have?

    A baloon? Zeppelin?

    Just take the plane.
    Just use PHPSELF (any of the above that works).

    Regards,
    Erwin Moller

    Comment

    • Jerim79

      #3
      Re: Alternatives to $PHPSELF

      On Feb 20, 8:43 am, Erwin Moller
      <since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
      Jerim79 wrote:
      My boss has saddled me with this task, so I don't know all the
      specifics. What I do know, is that I am looking for something similar
      to this:
      >
      <form action="<? echo $PHPSELF ?>" method="POST">
      >
      Syntax aside, I think you can see what we are trying to accomplish. We
      want to use PHP to call the exact same page that the form is on, for
      processing. I take it that the page with the form will also contain
      some PHP code that is executed when the page is reloaded. We want to
      be able to reload the page, independent of the page name. So that if
      we decide to rename the page foo.php or bar.php, it doesn't matter
      because the form reloads its own page by reference, and not by name.
      >
      Other than $PHPSELF, $PHP_SELF or $SERVER['PHP_SELF'] (that should
      just about cover it), what other options are there? I am looking for
      all possible ways to do this. If you want, please just respond with a
      keyword or a code snippet. I can research the details. Thank you in
      advance.
      >
      Hi Jerim,
      >
      Many browsers reload if the href of a hyperlink or the action in a form is
      empty. I wouldn't trust that behaviour, however...
      >
      But WHY do you not want to use the obvious good solutions you described
      yourself?
      >
      Sounds to me like: I want to fly to Autralia, and I know I can take a plane,
      but what other options do I have?
      >
      A baloon? Zeppelin?
      >
      Just take the plane.
      Just use PHPSELF (any of the above that works).
      >
      Regards,
      Erwin Moller
      My boss routinely gives me these types of assignments. Since I am
      junior in CS, and have been working at this company for less than six
      months, I take it that he is trying to give me some "learning"
      opportunities. Or perhaps he is just testing me, to see if I have the
      ability to come up with the answer.

      Comment

      • Captain Paralytic

        #4
        Re: Alternatives to $PHPSELF

        On 20 Feb, 14:33, "Jerim79" <m...@hotmail.c omwrote:
        My boss has saddled me with this task, so I don't know all the
        specifics. What I do know, is that I am looking for something similar
        to this:
        >
        <form action="<? echo $PHPSELF ?>" method="POST">
        >
        Syntax aside, I think you can see what we are trying to accomplish. We
        want to use PHP to call the exact same page that the form is on, for
        processing. I take it that the page with the form will also contain
        some PHP code that is executed when the page is reloaded. We want to
        be able to reload the page, independent of the page name. So that if
        we decide to rename the page foo.php or bar.php, it doesn't matter
        because the form reloads its own page by reference, and not by name.
        >
        Other than $PHPSELF, $PHP_SELF or $SERVER['PHP_SELF'] (that should
        just about cover it), what other options are there? I am looking for
        all possible ways to do this. If you want, please just respond with a
        keyword or a code snippet. I can research the details. Thank you in
        advance.
        I would suggest using the full tags as in <?php .... ?>

        Comment

        • Tim Van Wassenhove

          #5
          Re: Alternatives to $PHPSELF

          Jerim79 schreef:
          My boss has saddled me with this task, so I don't know all the
          specifics. What I do know, is that I am looking for something similar
          to this:
          >
          <form action="<? echo $PHPSELF ?>" method="POST">
          >
          Syntax aside, I think you can see what we are trying to accomplish. We
          want to use PHP to call the exact same page that the form is on, for
          processing. I take it that the page with the form will also contain
          some PHP code that is executed when the page is reloaded. We want to
          be able to reload the page, independent of the page name. So that if
          we decide to rename the page foo.php or bar.php, it doesn't matter
          because the form reloads its own page by reference, and not by name.
          >
          Other than $PHPSELF, $PHP_SELF or $SERVER['PHP_SELF'] (that should
          just about cover it), what other options are there? I am looking for
          all possible ways to do this. If you want, please just respond with a
          keyword or a code snippet. I can research the details. Thank you in
          advance.
          all the variants of $_SERVER['PHP_SELF'] have the flaw that they come
          from the user.. And thus are unsafe by definition...

          Afaik, if you use <form action="#" method="POST"al l browsers will post
          to the same URL that used to request the page. So you get the same
          behaviour, without the potential security issue.


          --
          Tim Van Wassenhove <url:http://www.timvw.be/>

          Comment

          • Curtis

            #6
            Re: Alternatives to $PHPSELF

            Tim Van Wassenhove wrote:
            Jerim79 schreef:
            >My boss has saddled me with this task, so I don't know all the
            >specifics. What I do know, is that I am looking for something similar
            >to this:
            >>
            ><form action="<? echo $PHPSELF ?>" method="POST">
            >>
            >Syntax aside, I think you can see what we are trying to accomplish. We
            >want to use PHP to call the exact same page that the form is on, for
            >processing. I take it that the page with the form will also contain
            >some PHP code that is executed when the page is reloaded. We want to
            >be able to reload the page, independent of the page name. So that if
            >we decide to rename the page foo.php or bar.php, it doesn't matter
            >because the form reloads its own page by reference, and not by name.
            >>
            >Other than $PHPSELF, $PHP_SELF or $SERVER['PHP_SELF'] (that should
            >just about cover it), what other options are there? I am looking for
            >all possible ways to do this. If you want, please just respond with a
            >keyword or a code snippet. I can research the details. Thank you in
            >advance.
            >
            all the variants of $_SERVER['PHP_SELF'] have the flaw that they come
            from the user.. And thus are unsafe by definition...
            >
            Afaik, if you use <form action="#" method="POST"al l browsers will post
            to the same URL that used to request the page. So you get the same
            behaviour, without the potential security issue.
            >
            >
            I use action="?". It works for either GET or POSTing.

            --
            Curtis, http://dyersweb.com

            Comment

            Working...