question about header() command and echo

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • runway27
    Banned
    New Member
    • Sep 2007
    • 54

    #1

    question about header() command and echo

    i have a question about using header("Locatio n: filename.html") ; in php

    with my present code i have a few echo statements followed by header("Locatio n: filename.html") ; because i have echo

    statements before header("Locatio n: filename.html") ; i am getting an error that headers have already been sent. i cannot

    remove the echo statements as they are doing an important task. based on this situation i can use echo followed by the html

    code for the filename in filename.html if i do this the code will run into a few 100's of lines and due to this i would like

    to use [php]header("Locatio n: filename.html") ;[/php]

    i have tried the following code and it works =
    Code:
    echo " <form name='errorpage' action='error.php' method='post'> </form> 	  
           <script type='text/javascript' language='javascript'> document.errorpage.submit(); </script> ";
    however if javascript is turned off this redirection will not work.

    could you please suggest if there is an alternative to using echo statement first followed by [php]header("Locatio n: filename.html") ; [/php]please advice.

    thanks.

    Please enclose any coding within the appropriate code tags - moderator
    Last edited by ronverdonk; Mar 3 '08, 05:24 PM. Reason: remove part
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Do not ask two questions in one thread. This is confusing and could lead to a mix-up of two different conversations. So I will remove the second part. Please open a new thread for that one.

    moderator

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      You can use a meta redirect:
      [code=html]
      <meta http-equiv="refresh" content="2;url= http://redirect.to.com ">
      [/code]

      Comment

      Working...