Jump to content

Warning: Cannot modify header information - headers already sent


tim101011

Recommended Posts

I have a page on my website that deletes pictures a user has uploaded. I am getting this error:

 

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/propertyeagle.co.uk/httpdocs/processdeletepostings.php:20) in /var/www/vhosts/propertyeagle.co.uk/httpdocs/processdeletepostings.php on line 79

 

And the user is not being redirected to the next page after the deletion as coded

 

Here is the code:

 

 


<?php 

session_start();

//check the user logged in legitamatley if not redirect them to the login page

                      if ($_SESSION['$specialcode']!=session_id()){
                      header("location:logonpage.htm");}


//connect to the db

require_once ('./connecttodb.php');


//delete selected postings from db and check if anything was selected

$a=0;
if ($_POST['C1']!="") {
$id = $_POST['C1'];
$query= "DELETE from property where id= '$id'";
$result = @mysql_query ($query);
$a=1; echo $id;
deletepictures($id); 
}

        if ($_POST['C2']!="") {
$id = $_POST['C2'];
$query= "DELETE from property where id= '$id'";
$result = @mysql_query ($query);
$a=1;
deletepictures($id);
}


if ($_POST['C3']!="") {
$id = $_POST['C3'];
$query= "DELETE from property where id= '$id'";
$result = @mysql_query ($query);
$a=1;
deletepictures($id);
}


function deletepictures($id)

{

                     if (file_exists ("uploads/".$id."a.jpg")) {unlink ("uploads/".$id."a.jpg");} 
if (file_exists ("uploads/".$id."b.jpg")) {unlink ("uploads/".$id."b.jpg");} 
if (file_exists ("uploads/".$id."c.jpg")) {unlink ("uploads/".$id."c.jpg");} 
if (file_exists ("uploads/".$id."d.jpg")) {unlink ("uploads/".$id."d.jpg");} 
if (file_exists ("uploads/".$id."e.jpg")) {unlink ("uploads/".$id."e.jpg");} 

if (file_exists ("uploads/".$id."a.gif")) {unlink ("uploads/".$id."a.gif");} 
if (file_exists ("uploads/".$id."b.gif")) {unlink ("uploads/".$id."b.gif");} 
if (file_exists ("uploads/".$id."c.gif")) {unlink ("uploads/".$id."c.gif");} 
if (file_exists ("uploads/".$id."d.gif")) {unlink ("uploads/".$id."d.gif");} 
if (file_exists ("uploads/".$id."e.gif")) {unlink ("uploads/".$id."e.gif");} 


if (file_exists ("uploads/".$id."a.bmp")) {unlink ("uploads/".$id."a.bmp");} 
if (file_exists ("uploads/".$id."b.bmp")) {unlink ("uploads/".$id."b.bmp");} 
if (file_exists ("uploads/".$id."c.bmp")) {unlink ("uploads/".$id."c.bmp");} 
if (file_exists ("uploads/".$id."d.bmp")) {unlink ("uploads/".$id."d.bmp");} 
if (file_exists ("uploads/".$id."e.bmp")) {unlink ("uploads/".$id."e.bmp");} 

}






//check how many active postings the user has and store the value in the session
// variable used for navigation link activation/ deactivation

$userid = $_SESSION['user_id'];
$sql="SELECT * FROM property WHERE userid='$userid'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
$_SESSION['postings'] = $count;

//redirect to search page

if ($a==1){header("location:searchproperties.php?id=deletesuccesfull");}
else {header("location:deletepostings.php");}


?>


 

Any ideas? I have already positioned the "session_start();" statement at the very top.

 

Thankyou kindly

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.