...

View Full Version : header location problem



sunnynosid
02-26-2012, 06:36 AM
This is my code to redirect to a different page when a row is deleted:

<?
session_start();
if($_SESSION[count]!==1){header("Location:http://www.mysite.com/mainsite/LoginReg/Login/loginform.php");};

$surity=$_POST['surity'];
echo"$surity";
mysql_connect('localhost', 'user', 'password') or die (mysql_error());
mysql_select_db('mydb') or die (mysql_error());

if($surity=yes){
$sql="DELETE FROM table WHERE Username='$_SESSION[username]' AND Password='$_SESSION[password]'";
mysql_query($sql);
header("location:http://www.mysite.com/mainsite/DelAcc/accdeleted.php");
}else{header("location:http://www.mysite.com/mainsite/DelAcc/accnotdeleted.php");};
mysql_close();
?>

But i am getting following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/mainsite/DelAcc/delaccscript.php:6) in /home/user/public_html/mainsite/DelAcc/delaccscript.php on line 13

Please tell me where the problem is?:mad:

elitis
02-26-2012, 08:08 AM
1) Please remember to use the code/php tags

2) Your getting that error because header() must be called before any actual output is sent. (i.e echo)

tangoforce
02-26-2012, 11:08 AM
You also need a space after Location: like this:
Location: <url>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum