Page Redirection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • assgar
    New Member
    • Aug 2006
    • 41

    Page Redirection

    Hello

    I am working on a search page. When you type the person's
    name insted of displaying a listing I want to be redirectd to
    the user information.

    I am getting a warninig:
    Warning: cannot modify header information - headers already
    sent( at start of D:\search.php: 108) in d:\search_play. php on line 242

    How can suggest a way I redirect or be automatically sent to a nother
    page without using header()?


    [Html]

    //search.php is the html form
    <form action="<php echo $SERVER['PHP_SELF'];?>" method = "post"> <!--line 108-->

    [/html]


    [php]
    <?
    //search_play.php process and display results
    header("Locatio n:../user_info.php") ; //line 242

    ?>
    [/php]
  • testuser
    New Member
    • Dec 2006
    • 6

    #2
    you can use ob_start(); at the beginning of the code

    theres probably a cleaner way to do this thojugh

    Comment

    • TheMadMidget
      New Member
      • Oct 2006
      • 98

      #3
      Its seems that you have a form the proceeds to another page with the information. From that you then trying to reroute to the correct page. If that is correct then no text/html should be displayed on the intermediate page. If there is any before the header(location ) then it will error. Check on that. That would be the correct way to do so.

      If you need a quick fix for the time being, just insert a javascript code.
      [php]
      echo "<script>docume nt.location='" . $location . "';</script>";
      [/PHP]

      Comment

      • seangates
        New Member
        • Dec 2006
        • 19

        #4
        To be very clear: you cannot output anything (HTML,CSS,JavaS cript) before redirection.

        Therefore, move any processing of the page (error_checking , database transactions) above/before ANY output.

        Use some variables and leave the output for later.

        Hope that makes it clearer.
        Sean

        Comment

        Working...