Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 25
  1. #11
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    I have tried concoctenating with the header() function but that never worked for me either. try building the address and storing it in a variable like this:

    PHP Code:
    $address "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/".$relative_url); 
    header ("location: $address");
    exit; 
    what is exit("Some Message") supposed to do? i have never seen it.
    eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.

  2.  

  3. #12
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    I've got to fix it, it was strange:
    I had a "print $blahblah" expression above the header() thing, and that was the problem, I have comment out that expression and it works... weird.

    exit("A error ocurred"); simply exits and prints "A error ocurred".

  4. #13
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    Yep, that's what I mean by
    You can't have any html before header();exit;
    The header() function sends out special data before the actual documents. I don't know the full details, but its usually just filetype information, cookie data and stuff like that, things you normally don't see. This link has the full details I think: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html.

    So when you use print(), php sees you haven't sent out the headers yet, spits out the default headers, and then starts the normal document output. Then it encounters header(), and reports an error.

    If you really need to use print() or echo before header, you can get around it with Output Buffering, where all your output is held in memory rather than spat out onto the web immediately.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  5. #14
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    Wow, Thanks

  6. #15
    Senior Member teal's Avatar
    Join Date
    Dec 2003
    Posts
    247
    Member #
    4319
    If you do a header redirect, will the code beneath it still be executed, or will you quit your script? If it does, can you set a time on it, the same as with its "meta" counterpart?
    Whoth steps forth to mock the teal? Whom couldst say a color superior!

    Proclamith me, it cannot be done.

  7. #16
    Senior Member teal's Avatar
    Join Date
    Dec 2003
    Posts
    247
    Member #
    4319
    -Nevermind, I tested it out and it parses first.
    Whoth steps forth to mock the teal? Whom couldst say a color superior!

    Proclamith me, it cannot be done.

  8. #17
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    Quote Originally Posted by teal
    If you do a header redirect, will the code beneath it still be executed, or will you quit your script? If it does, can you set a time on it, the same as with its "meta" counterpart?
    That might be a big problem teal... I think the client browser may effectively cancel the script after it receives header('location: ...');.

    Its probably best to process the form, then write out HTML with a meta redirect, ie
    HTML Code:
    <?php
    // Process form
    ?>
    <html>
    <head>
    ...
    <meta http-equiv="refresh" content="0; newlocation.php" />
    ...
    </head>
    <body>
    <p>Processing done! If page does not refresh, click on this link:</p>
    <p><a href="newlocation.php">newlocation.php</a></p>
    </body>
    That's what things like phpBB do.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  9. #18
    Senior Member visualAd's Avatar
    Join Date
    Jan 2003
    Location
    Slough, UK
    Posts
    201
    Member #
    434
    The browser will often terminate the connection on receiving a redirect - as the body of the response is non existant. If you want the script to continue executing after the connection is closed then you'll need to use the ignore_user_abort() function.

    Be careful using this function though as your script will not be able to produce any output after the connection is closed. Any output it does generate willl be lost in oblivion - this includes error messages.

    IMHO it is better to process the form without producing any output and then redirecting the client based on the result. You can also use output buffering to control when and where your PHP script produces output. When you use output buffering you can send a headers from anywhere in your script.

  10. #19
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    I got around this problem like this:
    Place this at the beginning of the script:
    PHP Code:
    ob_start(); 
    And at the end put this:
    PHP Code:
    ob_end_flush(); 
    That will collect all the output so the "header" will work.
    For the time delay you can use this:
    PHP Code:
    header ("refresh: 5; banana.php"); 
    That will delay it in 5 seconds.
    Hope this was of help

  11. #20
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    OK, so you can use header() still, but do your processing without echo()ing anything. This is a complex matter, but I think it's sorted out.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)


Page 2 of 3 FirstFirst 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:43 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com