/    Sign up×
Community /Pin to ProfileBookmark

Warning: Cannot modify header information – headers already sent by (output started at C:Program FilesxampphtdocsStaffLogin.php:6) in C:Program FilesxampphtdocsStaffLogin.php on line 29.

Throw the above Warning not executing the code………..

header(“location: http://localhost/StafDetail.php“);

Even not send data to the browser.

This is my php code,
—————–

<?PHP

$uNameErr = $pwdErr = “”;
$name = $pwd = “”;

if ($_SERVER[“REQUEST_METHOD”] == “POST” && $_POST[“btnEnter”] == 1 ) {

$action=-1;

if (empty($_POST[“txtUName”])) {
$uNameErr = “Name is required” ;
} else {
$name = test_input($_
POST[“txtUName”]);

}

if (empty($_POST[“txtPwd”])) {
$pwdErr = “Password is required”;
} else {
$pwd = test_input($_
POST[“txtPwd”]);
$action=1;

}
if($action==1){
header(“location: http://localhost/StafDetail.php”);exit;
}

}
—-

How to avoid this error.

Regards,
Sivakumar

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJul 24.2015 — You have something being sent to the client prior to the header command. Look for blank lines, extra blank spaces at the ends of a line, anything that goes to the browser. That means look for things outside of the php tags.
Copy linkTweet thisAlerts:
@JadJul 24.2015 — if you have a form (using <form> tags) the problem is prop in the action = "" part
Copy linkTweet thisAlerts:
@ginerjmJul 24.2015 — huh?

The problem is probably before the ?PHP tag since you don't show us any other non-php mode code
×

Success!

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