/    Sign up×
Community /Pin to ProfileBookmark

PHP redirection

Can i redirect to a page when a condition becomes true in PHP?
(something similar to response.redirect [ASP])


————————————————————————

  • 1. I tried using the header function but it gives the following warning:
  • Warning: Cannot modify header information – headers already sent by (output started at c:filenamephppage.php:12) in
    c:filenamephppage.php on line “line-number”

  • 2. I also tried using javascript:
  • echo “<script> self.location(“file.php”);</script>”;

    This too gives an error.


    ————————————————————————-

    HELP !!!


    ————————————————————————-

    Thank You!

    to post a comment
    PHP

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @NogDogJan 30.2006 — You need to ensure that there is not output to the browser before your call to the header() function, including anything before your opening <?php tag; even spaces or newlines.

    Alternatively, you could use ob_start() and ob_flush() to delay output, but usually some simple rearrangement of code logic (and elimination of white space before the <?php tag) will fix it without resorting to use of the ob_*() functions.

    Another alternative would be to add a "meta redirect" to your HTML head section.
    Copy linkTweet thisAlerts:
    @php_dudetteauthorJan 30.2006 — Thanx :-)
    ×

    Success!

    Help @php_dudette spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...