Search code examples
javascriptphpjqueryhtmlhref

Why should I click double on an 'a href' attribute to reload the page?


I have such a problem:

When I click on the element the url changes but PHP code doesn't run, but when I click it again or just push 'Enter' in the url, or push F5 the page reloads and PHP code runs

        <a href="?action=out" title="Forget me!">
            <img src="images/icons/exit.png" id="exit" class="ava">
        </a>

Here was my html code. Here is PHP one:

        if($_GET['action']=='out')
           {
               //do smth. here
            }

What is the problem, I just can't get it..

maybe I just have to use JS (location.reload() and so on), but I think that it will be not a good descision...

Thank you in advance!


Solution

  • I believe your href is wrong you have information in the href but no page assigned, if you are sourcing your own page try

    <a href="<?php echo $_SERVER['PHP_SELF'].'?action=out'; ?>" title="Forget Me!">