+ 2
Warning: Cannot modify header information - headers already sent by (output started at)
please fix this code wml chat.. help me if($admin=="6"){ header ('Location: ../tools/yourbooted.php?nimi=$nimi');} $status=file('../text/bannames.txt'); for ($ri=0; $ri<count($status); $ri++) {
8 Answers
+ 2
You can't use header after a function that produces an output (ex. print, echo or raw html).
Check the behavior of the code in the previous lines.
+ 1
can u make a simple code for me sir?
+ 1
To solve this problem it's necessary to check if the flow of the script produces some kind of output before header call.
ex.
print "test"; // <-- this print it's a problem if $admin = 6
if($admin=="6"){
header ('Location: ../tools/yourbooted.php?nimi=$nimi');}
you should remove all print function before header.
I also suggest you to put "exit" after "header" because this function sends the http header (redirect in this case) but doesn't stop the execution of the script.
ex.
if($admin=="6"){
header ('Location: ../tools/yourbooted.php?nimi=$nimi');
exit;
}
without exit you may have problems with print functions even after calling header.
+ 1
bro. this my full code. can u fix it?
<?php
$status=file('../text/bannames.txt');
for ($ri=0; $ri<count($status); $ri++)
{
$resultban=rtrim($status[$ri]);
if($nimi=="$resultban"){$admin="5";}
}
if($admin=="5"){
echo '<meta http-equiv="Refresh" Content="0; URL=../tools/yourbanned.php">';}
$status=file('../text/bootnames.txt');
for ($ri=0; $ri<count($status); $ri++)
{
$resultboot=rtrim($status[$ri]);
if($nimi=="$resultboot"){$admin="6";}
}
if($admin=="6"){
echo '<meta http-equiv="Refresh" Content="0; URL=../tools/yourbooted.php">';}
$status=file('../text/bannames.txt');
for ($ri=0; $ri<count($status); $ri++)
{
$resultipban=rtrim($status[$ri]);
if($nimi=="$resultipban"){$admin="8";}
}
if($admin=="8"){
echo '<meta http-equiv="Refresh" Content="0; URL=../tools/yourbooted.php">';}
?>
+ 1
Try add "exit;" after each occurrence of header
0
bro this my full code. can u fix it?
<?php
$status=file('../text/bannames.txt');
for ($ri=0; $ri<count($status); $ri++)
{
$resultban=rtrim($status[$ri]);
if($nimi=="$resultban"){$admin="5";}
}
if($admin=="5"){
header ('Location: ../tools/yourbanned.php');}
$status=file('../text/bootnames.txt');
for ($ri=0; $ri<count($status); $ri++)
{
$resultboot=rtrim($status[$ri]);
if($nimi=="$resultboot"){$admin="6";}
}
if($admin=="6"){
header ('Location: ../tools/yourbooted.php?nimi=$nimi');}
$status=file('../text/bannames.txt');
for ($ri=0; $ri<count($status); $ri++)
{
$resultipban=rtrim($status[$ri]);
if($nimi=="$resultipban"){$admin="8";}
}
if($admin=="8"){
header ('Location: ../tools/yourbanned.php');}
?>
0
make a example code bro. please.. i know u pro.. masta
0
This is my version of your code without repetitions and superfluous variables.
<?php
$files = array(
"bannames",
"bootnames"
);
for($i = 0; $i < count($files); $i++) {
$status=file("../text/".$files[$i].'.txt');
for ($ri=0; $ri<count($status); $ri++) {
$result=rtrim($status[$ri]);
if($nimi==$result) {
header("Location: ../tools/".($i == 0 ? "yourbanned.php" : "yourbooted.php?nimi=$nimi"));
exit;
}
}
}
?>
I think you can fix your code simply by adding exit for each header, ex.
if($admin==8) {
header('Location: ../tools/yourbanned.php');
exit;
}