/    Sign up×
Community /Pin to ProfileBookmark

Header("Location: ") Problem

I am working on a basic calculator script, here is what the first if statement says for if nothing is entered:

[CODE]
<?php
if (($_POST[val1] == “” ) || ($_POST[val2] == “”) || ($_POST[calc] == “”))
{
header(“Location: http://localhost/calculate_form.html”);
exit;
}[/CODE]

However, I keep getting an error saying “Warning: Cannot modify header information – headers already sent by…” and then the address of the PHP script.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@agrestikFeb 10.2007 — Hi Ascendancy,

Verify where this is placed in your page When you get this error, it is often because there is some HTML output before the script. You will probably fix this easily by putting your script at the beginning of the page.
Copy linkTweet thisAlerts:
@phpshift2Feb 12.2007 — *oops, I was wrong*

*Please delete this post*
×

Success!

Help @Ascendancy 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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