Button with refresh function

Discussion in 'PHP' started by hrdmn, Jun 9, 2007.

  1. #1
    Hey everybody ..
    every one of you knows the refresh button in every browser and accordingly it function.
    Can anyone tell me how to make a text/button/image in a web site to have the same function?
     
    hrdmn, Jun 9, 2007 IP
  2. stOx

    stOx Notable Member

    Messages:
    6,426
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    230
    #2
    just link to the page you want to refresh with php_self.
    <a href="<?php echo $_SERVER["PHP_SELF"] ?>">Refresh</a>
    Code (markup):
     
    stOx, Jun 9, 2007 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    You'd be better off using REQUEST_URI as that includes the request_uri of the document, PHP_SELF is the script name only.

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script language="javascript">
    function reloadPage( )
    {
    	document.location.href = '<?=$_SERVER['REQUEST_URI'] ?>';
    }
    </script>
    </head>
    
    <body>
    <input type="submit" name="refresh" value="Refresh" onclick="reloadPage();" />
    <a href="javascript:reloadPage();">Refresh</a>
    </body>
    </html>
    
    PHP:
     
    krakjoe, Jun 9, 2007 IP
  4. hrdmn

    hrdmn Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks, krakjoe!

    that's what i need cause when i tried php_self.. it turned me back to my homepage... so that works just fine ;)

    thanks a lot again!
     
    hrdmn, Jun 9, 2007 IP