Results 1 to 8 of 8

Thread: [RESOLVED] Header redirect

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2009
    Posts
    49

    Resolved [RESOLVED] Header redirect

    I currently have an order page that has three functions:

    1. Displays the order with a submit button
    2. Redirects to a payment page
    3. Displays results of the payment

    For step 2 - I want it to redirect to the payment page, but it won't because there is html code before the header code.

    I have tried moving the redirect code to the top before html but it still doesn't work. It does work if I move the call to the functions there as well but this of course means that 1. and 3. display up the top, not in my html template.

    Is anyone able to help me out on this? ... currently it just refreshes and shows nothing within the template rather then redirecting. If I echo out $url its all there... just doesn't redirect.

    Heres a simple code example:

    PHP Code:
    <?php
    //start the session and connect to db
    session_start();
    ?>
    <html>
    <head>
    <title>Page title</title>
    <meta name="description" value="" />
    </head>
    <body>

    <?php 
    //Functions
      
    if (isset($_REQUEST["result"]))
      {
        
    # this is a redirection from the payments page.
        
    print_result();
      }
      elseif (isset(
    $_REQUEST["submit"]))
      {
        
    # this is a post back -- redirect to payments page.
        
    redirect_form();
      }
      else
      {
        
    # this is a fresh request -- display order with a submit button
        
    print_form();
      }
    ?>
    <table width="100%"  border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td>Logo</td>
      </tr>
      <tr>
        <td>
    <?php
    function print_form()
    {
        
    //show order
    }    

    function 
    print_result()
    {
        
    //show payment successful or not successful message
    }
        
    function 
    redirect_form()
    {
        
    //redirect to payment page
        
    header("Location: ".$url);
          exit;
    }
    ?>
        </td>
      </tr>
    </table>
    </body>
    </html>
    Last edited by buffy; Jan 5th, 2010 at 09:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width