SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    isset() with text link

    hi

    i know how to use isset() with submit buttons

    But if i have a text link

    Code:
    <a href="2">link 2</a>
    then how will i check it with

    Code:
    if(isset())
    vineet

  2. #2
    Founder of Primal Skill Ltd. feketegy's Avatar
    Join Date
    Aug 2006
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The anchor element is not a form element, therefore it doesn't get passed to $_POST if that's what you're referring to... you need to use input or button elements.

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by feketegy View Post
    The anchor element is not a form element, therefore it doesn't get passed to $_POST if that's what you're referring to... you need to use input or button elements.
    Or you have to provide a querystring variable you can check such as
    Code:
    <a href="2?pageSet=true">link 2</a>
    To check it
    PHP Code:
    if (isset($_GET['pageSet']))
    {


  4. #4
    Founder of Primal Skill Ltd. feketegy's Avatar
    Join Date
    Aug 2006
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Or you have to provide a querystring variable you can check such as
    Code:
    <a href="2?pageSet=true">link 2</a>
    To check it
    PHP Code:
    if (isset($_GET['pageSet']))
    {

    That's one of the worst answers I saw...

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,129
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by feketegy View Post
    That's one of the worst answers I saw...
    Unfortunately that neither helps or provides anything meaningful. The person asked for how you would be able to recognize a link was clicked, I provided a simple example. Would you likely use that in a real environment, maybe not, but tell me how many times do you see the following:
    Code:
    <a href="mydomain.com/?logout=true">Logout</a>
    Now tell me how that is any better than what I provided?

    It isn't and you would use the same process to actually log the person out of your website. There isn't any issue with XSS or CSRF in my example, nor does it have any problems against best practices.

  6. #6
    Founder of Primal Skill Ltd. feketegy's Avatar
    Join Date
    Aug 2006
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Unfortunately that neither helps or provides anything meaningful. The person asked for how you would be able to recognize a link was clicked, I provided a simple example. Would you likely use that in a real environment, maybe not, but tell me how many times do you see the following:
    Code:
    <a href="mydomain.com/?logout=true">Logout</a>
    Now tell me how that is any better than what I provided?

    It isn't and you would use the same process to actually log the person out of your website. There isn't any issue with XSS or CSRF in my example, nor does it have any problems against best practices.
    Your answer is misleading, the OP is clearly a beginner in programming, you provide a piece of unsecure code just to answer his question. It's fine to provide answers like this, but don't forget to mention that is bad practice to use it. Why not mention to use POST instead of GET? etc.


    ...but tell me how many times do you see the following:
    Code:
    <a href="mydomain.com/?logout=true">Logout</a>
    I never saw this kind of logout anywhere in production code. And yes, it's a bad practice to do this way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •