/    Sign up×
Community /Pin to ProfileBookmark

Cannot modify header information error

I’m using this php code to login users.

[code=php]<?php
$name = $_POST[‘name’];
$pass = $_POST[‘pass’];
if($name == “Joan Jones” && $pass == “karen94”){setcookie(“namec”, “Joan”);}
else {$namec = “person who is desperate enough to try and make up a valid login”;}
print “Hello, $namec”;
?>[/code]

Then I get this error message. Does anyone know what this means?

Warning: Cannot modify header information – headers already sent by (output started at /home/redriver/public_html/design/customers.php:10) in /home/redriver/public_html/design/customers.php on line 13

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@schizoSep 04.2005 — Make sure you have no HTML output before your PHP code in this instance.

"Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. If output exists prior to calling this function, setcookie() will fail and return FALSE."
Copy linkTweet thisAlerts:
@conputerguy99authorSep 04.2005 — Thank you so much! I've had this problem for a long time! THANK YOU!!!!!!!!!!!
Copy linkTweet thisAlerts:
@schizoSep 04.2005 — You're welcome. If you're using PHP 4 (or greater), you can also use output buffering to get around this problem. Additional information can be found here:

http://us2.php.net/manual/en/function.setcookie.php
×

Success!

Help @conputerguy99 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.20,
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,
)...