/    Sign up×
Community /Pin to ProfileBookmark

Issue redirecting users on form submission – ("Cannot modify header information…")

This form works …

Change $to variable to your address and the following …

$formurl = “http://localhost/test/apply2.htm” ;
$errorurl = “http://localhost/test/error.htm” ;
$thankyouurl = “http://localhost/test/thank_you.htm” ;

… my problem is that i can’t get the page to redirect to the above urls where necessary!

Please help!

Is there another way!?

[upl-file uuid=7a2fa2d6-f323-4616-b7da-7de18ff10af7 size=3kB]forum.zip[/upl-file]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 03.2007 — If you are going to do a header() redirect, then [i]nothing[/i] can be output by the script before that call to header(). Output can be anything that is echo()'d or print()'d, but also anything not inside of <?php...?> tags, [i]including spaces and newlines.[/i]

The error message should tell you a line number where output was started, in case it's just a case of eliminating extraneous white-space that has been output. Otherwise you may have to change your code logic/flow so that the header() redirection comes before any output. Alternatively you could look into using [url=http://www.php.net/ob_start]output buffering[/url].
Copy linkTweet thisAlerts:
@new_cssauthorMay 04.2007 — Hi

Yep i think it's a chicken and egg logic/flow situation ... i have to set the headers to redirect so if i deliberately leave the email section blank so that it should forward to the error page i get an error on line 30 whereas if i do everything properly i get an error on line 121 where i attempt to send the user to a thank-you page ....

anyone any ideas?
Copy linkTweet thisAlerts:
@stephan_gerlachMay 04.2007 — Your problem is easy to fix.

make sure that at the top of the file you have the following

[code=php]<?php
ob_start();

?>[/code]


have nothing before the ob_start(); and make sure there is not even a space or line break before the <?php

ob_start(); is an output buffer and will collect all output until the end of the script is reached. Then the content will be sent to the browser.

Hope that helps.
Copy linkTweet thisAlerts:
@new_cssauthorMay 04.2007 — Thank you, thank you, thank you Stephan!!

x
×

Success!

Help @new_css 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...