problem with header("refresh: 5; $url"); command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tabariz
    New Member
    • Apr 2008
    • 1

    problem with header("refresh: 5; $url"); command

    Hello everybody
    can anyone tell me whats the correct syntax to add a variable previously declared to the url in the command header("refresh : 5, url:)
    for example i want my URL to be
    http://www.mibax.com/services/service1.php(mo re than one variables attached here)
    can anyone tell me how to do so?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by tabariz
    Hello everybody
    can anyone tell me whats the correct syntax to add a variable previously declared to the url in the command header("refresh : 5, url:)
    for example i want my URL to be
    http://www.mibax.com/services/service1.php(mo re than one variables attached here)
    can anyone tell me how to do so?
    Hey tab, welcome to bytes!

    You would just append the variables to the url in the header() function.

    Although, im not clear on your qeustion, to be honest.
    Can you explain a little more?

    Comment

    • mmffrooq
      New Member
      • May 2009
      • 2

      #3
      Originally posted by tabariz
      Hello everybody
      can anyone tell me whats the correct syntax to add a variable previously declared to the url in the command header("refresh : 5, url:)
      for example i want my URL to be
      http://www.mibax.com/services/service1.php(more than one variables attached here)
      can anyone tell me how to do so?

      replace ur header command with this 1 header("refresh :5;url=$url");

      Comment

      • unauthorized
        New Member
        • May 2009
        • 81

        #4
        Do you mean http://url?var1=val1&var2=val2 by variables?
        You can access these with the $_GET supperglobal variable. Look it up on php.net.

        Code:
        // replace var1 with the name of your variable
        if(isset($_GET['var1']))
             header("refresh: 5; {$_GET['var1']}");

        Comment

        • mmffrooq
          New Member
          • May 2009
          • 2

          #5
          Originally posted by unauthorized
          Do you mean http://url?var1=val1&var2=val2 by variables?
          You can access these with the $_GET supperglobal variable. Look it up on php.net.

          Code:
          // replace var1 with the name of your variable
          if(isset($_GET['var1']))
               header("refresh: 5; {$_GET['var1']}");
          bro {$_GET['var1'] means that u r getting some value from the page u r directed from n tabraiz assigned $url variable already wid sum value like as u sayng maybe he assigned $url=$_GET['var1']; thats what i was wantd to say sowi for ma weak english :P

          Comment

          • webdeveloper

            #6
            hi to all you can do that like this three examples below two of them with php and one with html :
            1. header('Locatio n: url') Example : header('Locatio n: example.php'); or header('Locatio n: http://www.example.com'); (Redirect URL Or Page)
            2. header( 'refresh: 5; url=example.php '); or header('refresh : 5; url=http://www.example.com '); (Redirect URL OR PAGE in 5 Seconds)
            3. echo '<meta name http-equiv=Refresh Content="5;url= example.php'; or echo '<meta name http-equiv="refresh" Content="5;url= http://www.example.com " '; (Redirect URL OR PAGE in 5 Seconds)
            Last edited by Dormilich; Oct 8 '10, 05:45 AM.

            Comment

            Working...