/    Sign up×
Community /Pin to ProfileBookmark

I have code for validation of user:

[code=php]
<?php
//search for name
/* Connect to MySQL-Server */

/* Open $db */

$un = $_POST[‘usernameop’];

if (isset($_POST[‘fnameop’]))
{

$query = “SELECT * FROM users WHERE user=’$un’ LIMIT 1”;
$result = mysql_query($query) or die (“SQL error: $query — ” . mysql_error());
while ($row = mysql_fetch_array($result))
{
$validation_search = TRUE;
}
}

?>
[/code]

I have this code included in my primary page. But it gives me anwser:
Warning: Cannot modify header information – headers already sent by (output started at validation_search.php:11) in index.php on line 50

I have all the time problem with this, what is here output that causes error?

In index there is:

[code=php]
include (“validation_search.php”);
if ($validation_search == TRUE)
{ header(‘Location: home.php’);}
[/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@bambolinOct 05.2005 — you can use header if you have outputted something to the page. You are trying to set a header but the headers have already been sent because you have outputted to the page that is why it is giving you that error!
Copy linkTweet thisAlerts:
@emin3mOct 05.2005 — http://www.webdeveloper.com/forum/showthread.php?t=81073

check this thread i have answered there ( post # 3)
Copy linkTweet thisAlerts:
@toplisekauthorOct 05.2005 — Where are here headers that I have already been sent because I have outputted to the page In which line, please help
Copy linkTweet thisAlerts:
@LimpBagelOct 05.2005 — If [B]anything[/B] is outputted to the browser before a header call you will get that error.
Copy linkTweet thisAlerts:
@toplisekauthorOct 06.2005 — If I understand, there should not be any code in INCLUDE FILE like:

<?php

bla blaa bla bla bal

?>

this is already defined as 'OUTPUTTED' even it is just simple code?
Copy linkTweet thisAlerts:
@emin3mOct 06.2005 — check and remove extra spaces before and after <?php ?>

nothing should be outputted in you include file ( no echo , no print .. etc )

now as your include file is just code only header function will work now

or just replace header function with the code i gave in other thread
Copy linkTweet thisAlerts:
@toplisekauthorOct 19.2005 — Thanks it works.
×

Success!

Help @toplisek 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.11,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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