Jump to content

Cannot modify header information error, i have read the headers...


jesushax

Recommended Posts

Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux153/c/cwservicesltd.co.uk/user/htdocs/admin/portfolio/edit_project.php:31) in /home/fhlinux153/c/cwservicesltd.co.uk/user/htdocs/admin/portfolio/edit_project.php on line 208

 

line 208 is obviously header("Location: /admin/portfolio/index.php");

 

ive read the headers sticky checked everypage for whitespace rearranged stuff that didnt need rearraging and still i get the same thing :(

 

any other hints?

 

<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');
?>
<div id="subs-container">
<div id="subs">
<div id="subs-admin-text">
<div class="padding">
<ul>
<li class="menu">Portfolio Menu:</li>
<li class="menu"><a href="/admin/portfolio/add_project.php">Add</a></li>
<li class="menu"><a href="/admin/portfolio/index.php">View/Edit</a></li>
<li class="menu"><a href="/admin/portfolio/current_projects.php">Current Projects</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="lower-container">
<div id="backlinks"><?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/backlinks.php'); ?></div>
<div id="content">
<div class="padding">
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({xhtml:true}).panelInstance('txtCase');	
new nicEditor({xhtml:true}).panelInstance('txtResult');	
new nicEditor({xhtml:true}).panelInstance('txtBrief');	
new nicEditor({xhtml:true}).panelInstance('txtComments');	
});
</script>
<?php
function searchForThis($data, $search){
if (strstr($data, $search)){
	echo 'checked="checked"';}
}
$absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/portfolio/images/";//Absolute path to where files are uploaded
$thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/portfolio/images/thumbs/";   //Absolute path to where thumbs are to be stored if you want this
$size_limit = "yes";                                          //do you want a size limit yes or no.
$limit_size = "4000000";                                       //How big do you want size limit to be in bytes
$limit_ext = "yes";                                           //do you want to limit the extensions of files uploaded
$ext_count = "4";                                             //total number of extensions in array below
$extensions = array(".jpg", ".jpeg", ".png", ".gif");         //List extensions you want files uploaded to be

function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){
// SET THE IMAGE COMPRESSION
$g_imgcomp=100-$imgcomp;
  // CHECK TO SEE IF THE IMAGE EXISTS FIRST
  if(file_exists($sourcefile)){
  // FIRST WE GET THE CURRENT IMAGE SIZE
  $g_is=getimagesize($sourcefile);
    /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/
    // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE
    if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){
    // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE
    $new_width=$g_is[0];
    $new_height=$g_is[1];
    } else {
    // GET VALUE TO CALCULATE WIDTH AND HEIGHT
    $w_adjust = ($maxsize / $g_is[0]);
    $h_adjust = ($maxsize / $g_is[1]);
      // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT
      if($w_adjust <= $h_adjust){
      // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER
      $new_width=($g_is[0]*$w_adjust);
      $new_height=($g_is[1]*$w_adjust);
      } else {
      // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER
      $new_width=($g_is[0]*$h_adjust);
      $new_height=($g_is[1]*$h_adjust);
      }
    }
  //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." )
$image_type = strrchr($sourcefile, ".");

//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
	case '.jpg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.jpeg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.png':
		$img_src = imagecreatefrompng($sourcefile);
		break;
	case '.gif':
		$img_src = imagecreatefromgif($sourcefile);
		break;
	default:
		echo("Error Invalid Image Type");
		die;
		break;
}
  // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT
  $img_dst=imagecreatetruecolor($new_width,$new_height);
  // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT
  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]);
  // OUTPUT THE IMAGE AS A JPEG.
  // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE.
  imagejpeg($img_dst, $destination, 100);
  // DESTROY THE NEW IMAGE
  imagedestroy($img_dst);
  return true;
  } else {
  return false;
  }
}


switch(@$_GET["action"]){

    case "edit":
$i=0;
$insert_array = array();
  foreach ($_FILES["pictures"]["error"] as $key => $error) {
  $file_name =  $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name
  $file =  $_FILES["pictures"]['tmp_name'][$i];
  $file_size = $_FILES["pictures"]['size'][$i];
  $endresult = "<span style=\"color:#FF0000; font-size:10px;\">$file_name uploaded successfully</span>";
    if ($file_name == "") {
    $pic = $i+1;
    $endresult = "<span style=\"color:#FF0000; font-size:10px;\">Image# $pic Not selected</span>";
    }else{
      if(file_exists("$absolute_path/$file_name")) {
      $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File Already Existed</span>";
      } else {
        if (($size_limit == "yes") && ($limit_size < $file_size)) {
        $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File was to big</span>";
        } else {
        $ext = strrchr($file_name,'.');
          if (($limit_ext == "yes") && (!in_array($ext,$extensions))) {
          $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File is wrong type</span>";
          }else{
          $j = $i + 1;
          $ikey = "NewsImage$j";
          $insert_array[$ikey] = $file_name;
          // first move the file to
          move_uploaded_file($file, $absolute_path.$file_name);
          // Save full size image with max width/height
          resampleimage("400", $absolute_path.$file_name, $absolute_path.$file_name, 0);  // Comment this line out if you don't want to resize the image change the "800" to the size you want
          // Save thumb image with max width/height of 200
          resampleimage("150", $absolute_path.$file_name, $thumb_path.$file_name, 0); // Comment this line out if you don't want to create a thumbnail, change the 200 to the size you want

          }
        }
      }
    }
  $i++;
  echo $endresult."<br>";
  }

//$ext = strrchr($_FILES["pictures"]['name'][$i], ".");
//$n = $i+1;
//$file_name = "file".$n.$ext;

// mysql insert

$PortID = $_POST["txtID"];
$Company = $_POST["txtCompany"];
$Name = $_POST["txtName"];
$URL = $_POST["txtUrl"];
$Location = $_POST["txtLocation"];
$Logo = $_FILES['pictures']['name'][0];
$Image1 = $_FILES['pictures']['name'][1];
$Image2 = $_FILES['pictures']['name'][2];
$Image3 = $_FILES['pictures']['name'][3];
$Case = $_POST["txtCase"];
$Result = $_POST["txtResult"];
$Brief = $_POST["txtBrief"];
$CommentsTitle = $_POST["txtCommentsTitle"];
$Comments = $_POST["txtComments"];
$Date = date("d/m/y");

if (!empty($_POST["chkXHTML"])) {
$Services = ":".$_POST["chkXHTML"].":";}
if (!empty($_POST["chkWebDesign"])) {
$Services = $Services.":".$_POST["chkWebDesign"].":";}
if (!empty($_POST["chkCMS"])) {
$Services = $Services.":".$_POST["chkCMS"].":";}
if (!empty($_POST["chkOnlineDB"])) {
$Services = $Services.":".$_POST["chkOnlineDB"].":";}
if (!empty($_POST["chkPDF"])) {
$Services = $Services.":".$_POST["chkPDF"].":";}
if (!empty($_POST["chkMembership"])) {
$Services = $Services.":".$_POST["chkMembership"].":";}
if (!empty($_POST["chkBranding"])) {
$Services = $Services.":".$_POST["chkBranding"].":";}

$SQL = "UPDATE tblPortfolio Set ClientCompany='$Company', ClientName='$Name', ClientURL='$URL', ClientLocation='$Location', ";

if (!empty($Logo)) {
$SQL = $SQL."ClientLogo='$Logo', ";
}
if (!empty($PortImage1)) {
$SQL = $SQL."PortImage1='$Image1', ";
}
if (!empty($PortImage2)) {
$SQL = $SQL."PortImage2='$Image2', ";
}
if (!empty($PortImage3)) {
$SQL = $SQL."PortImage3='$Image3', ";
}

$SQL = $SQL."ClientCase='$Case', ClientResult='$Result', ClientBrief='$Brief', ClientServices='$Services',  ClientCommentsTitle='$CommentsTitle', ClientComments='$Comments', PortDateEdited='$Date' WHERE PortID='$PortID' ";

mysql_query($SQL) or die(mysql_error());

header("Location: /admin/portfolio/index.php");	
break;

default:
$extens = '';

        if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) {
           $extens = "any extension";
        } else {
        $ext_count2 = $ext_count+1;
        for($counter=0; $counter<$ext_count; $counter++) {
            $extens .= "  $extensions[$counter]";
        }
        }
        if (($limit_size == "") or ($size_limit != "yes")) {
            $limit_size = "any size";
        } else {
            $limit_size .= " bytes";
            $mb_size = ($limit_size/1000000);
        }
        $pichead = "<ul style=\"color:#FF0000; font-size:10px;\"><li style=\"display:inline; padding-right:10px;\">File extension must be $extens |</li>";
        $pichead .="<li style=\"display:inline; padding-right:10px;\">Maximum file size is $limit_size ($mb_size MB) |</li>
        			<li style=\"display:inline; padding-right:10px;\">No spaces in the filename</li></ul>";

$ID = $_GET["ID"];

$PortSQL = mysql_query("SELECT * FROM tblPortfolio WHERE PortID='$ID' ") or die(mysql_error());

while ($rsEdit = mysql_fetch_array($PortSQL)) {
?>
<h3>Edit Project</h3>
<form action="<?=$_SERVER['PHP_SELF']?>?action=edit" method="post" enctype="multipart/form-data" />
<input name="txtID" type="hidden"  value="<?php echo $rsEdit["PortID"]; ?>" />
<table width="100%">
<tr>
  <td><strong>Company Name:</strong></td>
  <td colspan="2"><input name="txtCompany" type="text" size="50" value="<?php echo $rsEdit["ClientCompany"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Client Name</strong></td>
  <td colspan="2"><input name="txtName" type="text" id="txtName" size="50" value="<?php echo $rsEdit["ClientName"]; ?>" /></td>
</tr>


<tr>
  <td><strong>Client Location</strong></td>
  <td colspan="2"><input name="txtLocation" type="text" id="txtLocation" size="50" value="<?php echo $rsEdit["ClientLocation"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Url:</strong></td>
  <td colspan="2"><input name="txtUrl" type="text" size="70" value="<?php echo $rsEdit["ClientURL"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Client Logo:</strong></td>
  <td><input type="file" name="pictures[]" size="50" /></td><td rowspan="3"><? echo $pichead; ?></td></tr>
<tr><td><strong>Image 1:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr><td><strong>Image 2:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr><td><strong>Image 3:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr>
  <td colspan="3"><strong>Client Brief / About the Client:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtBrief" style="width:550px; height:175px;"><?php echo $rsEdit["ClientBrief"]; ?></textarea></td>
<tr>
<tr>
  <td colspan="3"><strong>What the client wanted:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtCase" style="width:550px; height:175px;"><?php echo $rsEdit["ClientCase"]; ?></textarea></td>
<tr>
  <td colspan="3"><strong>Case result:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtResult" style="width:550px; height:175px;"><?php echo $rsEdit["ClientResult"]; ?></textarea></td>
<tr>
  <td colspan="3"><strong>Client Services</strong></td>
<tr>
  <td colspan="3">
<?php $data = $rsEdit["ClientServices"]; ?>
  <table width="50%" border="0">
    <tr>
      <td>XHTML/CSS Standards Compliant</td>
      <td><input type="checkbox" name="chkXHTML" value="XHTML/CSS Standards Compliant" class="blank"
       <?php $search = "XHTML/CSS Standards Compliant"; searchForThis($data, $search);?> /></td>
      <td>Form to PDF/Email</td>
      <td><input type="checkbox" name="chkPDF" value="Form to PDF/Email" class="blank"
      <?php $search = "Form to PDF/Email"; searchForThis($data, $search);?>  /></td>
    </tr>
    <tr>
      <td>Webpage Design</td>
      <td><input type="checkbox" name="chkWebDesign" value="Webpage Design" class="blank" id="chkWebDesign"
      <?php $search = "Webpage Design"; searchForThis($data, $search);?> /></td>
      <td>Membership System</td>
      <td><input type="checkbox" name="chkMembership" value="Membership System" class="blank"
      <?php $search = "Membership System"; searchForThis($data, $search);?> /></td>
    </tr>
    <tr>
      <td>Content Management System</td>
      <td><input type="checkbox" name="chkCMS" value="Content Mangement System" class="blank"
      <?php $search = "Content Mangement System"; searchForThis($data, $search);?> /></td>
      <td>Corporate Branding</td>
      <td><input type="checkbox" name="chkBranding" value="Corporate Branding" class="blank"
      <?php $search = "Corporate Branding"; searchForThis($data, $search);?> /></td>
    </tr>
    <tr>
      <td>Online Database</td>
      <td><input type="checkbox" name="chkOnlineDB" value="Online Database" class="blank"
      <?php $search = "Online Database"; searchForThis($data, $search);?> /></td>
      <td> </td>
      <td> </td>
    </tr>
  </table>  </td>
</tr>
<tr>
  <td> </td>
  <td colspan="2"> </td>
</tr>
<tr>
  <td><strong>Client Comments:</strong></td>
  <td colspan="2"><input name="txtCommentsTitle" type="text" size="50" value="<?php echo $rsEdit["ClientCommentsTitle"]; ?>" /></td>
</tr>

<tr>
  <td colspan="3"><textarea name="txtComments"  style="width:550px; height:175px;"><?php echo $rsEdit["ClientComments"]; ?></textarea></td>
</tr>
<tr>
<td colspan="3"><div style=" text-align:center">
<input type="submit" name="submit" value="Edit Project" />
<input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/portfolio/index.php'" />
</div></td>
</tr>
</table>
</form>
<?php
}
break;
}
include($_SERVER['DOCUMENT_ROOT'] . '/includes/logged_footer.php');
?>

like the code in header.php?

and the divs?

but i have this code on loads of pages and works fine, its just his uploading page that it does it on :S

 

herse the orginal code before i started trying to fix it

 

<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');
?>
<div id="subs-container">
<div id="subs">
<div id="subs-admin-text">
<div class="padding">
<ul>
<li class="menu">Portfolio Menu:</li>
<li class="menu"><a href="/admin/portfolio/add_project.php">Add</a></li>
<li class="menu"><a href="/admin/portfolio/index.php">View/Edit</a></li>
<li class="menu"><a href="/admin/portfolio/current_projects.php">Current Projects</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="lower-container">
<div id="backlinks"><?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/backlinks.php'); ?></div>
<div id="content">
<div class="padding">
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({xhtml:true}).panelInstance('txtCase');	
new nicEditor({xhtml:true}).panelInstance('txtResult');	
new nicEditor({xhtml:true}).panelInstance('txtBrief');	
new nicEditor({xhtml:true}).panelInstance('txtComments');	
});
</script>
<?php
function searchForThis($data, $search){
if (strstr($data, $search)){
	echo 'checked="checked"';}
}
$absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/portfolio/images/";//Absolute path to where files are uploaded
$thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/portfolio/images/thumbs/";   //Absolute path to where thumbs are to be stored if you want this
$size_limit = "yes";                                          //do you want a size limit yes or no.
$limit_size = "4000000";                                       //How big do you want size limit to be in bytes
$limit_ext = "yes";                                           //do you want to limit the extensions of files uploaded
$ext_count = "4";                                             //total number of extensions in array below
$extensions = array(".jpg", ".jpeg", ".png", ".gif");         //List extensions you want files uploaded to be

function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){
// SET THE IMAGE COMPRESSION
$g_imgcomp=100-$imgcomp;
  // CHECK TO SEE IF THE IMAGE EXISTS FIRST
  if(file_exists($sourcefile)){
  // FIRST WE GET THE CURRENT IMAGE SIZE
  $g_is=getimagesize($sourcefile);
    /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/
    // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE
    if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){
    // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE
    $new_width=$g_is[0];
    $new_height=$g_is[1];
    } else {
    // GET VALUE TO CALCULATE WIDTH AND HEIGHT
    $w_adjust = ($maxsize / $g_is[0]);
    $h_adjust = ($maxsize / $g_is[1]);
      // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT
      if($w_adjust <= $h_adjust){
      // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER
      $new_width=($g_is[0]*$w_adjust);
      $new_height=($g_is[1]*$w_adjust);
      } else {
      // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER
      $new_width=($g_is[0]*$h_adjust);
      $new_height=($g_is[1]*$h_adjust);
      }
    }
  //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." )
$image_type = strrchr($sourcefile, ".");

//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
	case '.jpg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.jpeg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.png':
		$img_src = imagecreatefrompng($sourcefile);
		break;
	case '.gif':
		$img_src = imagecreatefromgif($sourcefile);
		break;
	default:
		echo("Error Invalid Image Type");
		die;
		break;
}
  // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT
  $img_dst=imagecreatetruecolor($new_width,$new_height);
  // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT
  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]);
  // OUTPUT THE IMAGE AS A JPEG.
  // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE.
  imagejpeg($img_dst, $destination, 100);
  // DESTROY THE NEW IMAGE
  imagedestroy($img_dst);
  return true;
  } else {
  return false;
  }
}

if(!isset($_POST['submit'])){
$extens = '';

        if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) {
           $extens = "any extension";
        } else {
        $ext_count2 = $ext_count+1;
        for($counter=0; $counter<$ext_count; $counter++) {
            $extens .= "  $extensions[$counter]";
        }
        }
        if (($limit_size == "") or ($size_limit != "yes")) {
            $limit_size = "any size";
        } else {
            $limit_size .= " bytes";
            $mb_size = ($limit_size/1000000);
        }
        $pichead = "<ul style=\"color:#FF0000; font-size:10px;\"><li style=\"display:inline; padding-right:10px;\">File extension must be $extens |</li>";
        $pichead .="<li style=\"display:inline; padding-right:10px;\">Maximum file size is $limit_size ($mb_size MB) |</li>
        			<li style=\"display:inline; padding-right:10px;\">No spaces in the filename</li></ul>";

$ID = $_GET["ID"];

$PortSQL = mysql_query("SELECT * FROM tblPortfolio WHERE PortID='$ID' ") or die(mysql_error());

while ($rsEdit = mysql_fetch_array($PortSQL)) {
?>
<h3>Edit Project</h3>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" />
<input name="txtID" type="hidden"  value="<?php echo $rsEdit["PortID"]; ?>" />
<table width="100%">
<tr>
  <td><strong>Company Name:</strong></td>
  <td colspan="2"><input name="txtCompany" type="text" size="50" value="<?php echo $rsEdit["ClientCompany"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Client Name</strong></td>
  <td colspan="2"><input name="txtName" type="text" id="txtName" size="50" value="<?php echo $rsEdit["ClientName"]; ?>" /></td>
</tr>


<tr>
  <td><strong>Client Location</strong></td>
  <td colspan="2"><input name="txtLocation" type="text" id="txtLocation" size="50" value="<?php echo $rsEdit["ClientLocation"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Url:</strong></td>
  <td colspan="2"><input name="txtUrl" type="text" size="70" value="<?php echo $rsEdit["ClientURL"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Client Logo:</strong></td>
  <td><input type="file" name="pictures[]" size="50" /></td><td rowspan="3"><? echo $pichead; ?></td></tr>
<tr><td><strong>Image 1:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr><td><strong>Image 2:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr><td><strong>Image 3:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr>
  <td colspan="3"><strong>Client Brief / About the Client:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtBrief" style="width:550px; height:175px;"><?php echo $rsEdit["ClientBrief"]; ?></textarea></td>
<tr>
<tr>
  <td colspan="3"><strong>What the client wanted:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtCase" style="width:550px; height:175px;"><?php echo $rsEdit["ClientCase"]; ?></textarea></td>
<tr>
  <td colspan="3"><strong>Case result:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtResult" style="width:550px; height:175px;"><?php echo $rsEdit["ClientResult"]; ?></textarea></td>
<tr>
  <td colspan="3"><strong>Client Services</strong></td>
<tr>
  <td colspan="3">
<?php $data = $rsEdit["ClientServices"]; ?>
  <table width="50%" border="0">
    <tr>
      <td>XHTML/CSS Standards Compliant</td>
      <td><input type="checkbox" name="chkXHTML" value="XHTML/CSS Standards Compliant" class="blank"
       <?php $search = "XHTML/CSS Standards Compliant"; searchForThis($data, $search);?> /></td>
      <td>Form to PDF/Email</td>
      <td><input type="checkbox" name="chkPDF" value="Form to PDF/Email" class="blank"
      <?php $search = "Form to PDF/Email"; searchForThis($data, $search);?>  /></td>
    </tr>
    <tr>
      <td>Webpage Design</td>
      <td><input type="checkbox" name="chkWebDesign" value="Webpage Design" class="blank" id="chkWebDesign"
      <?php $search = "Webpage Design"; searchForThis($data, $search);?> /></td>
      <td>Membership System</td>
      <td><input type="checkbox" name="chkMembership" value="Membership System" class="blank"
      <?php $search = "Membership System"; searchForThis($data, $search);?> /></td>
    </tr>
    <tr>
      <td>Content Management System</td>
      <td><input type="checkbox" name="chkCMS" value="Content Mangement System" class="blank"
      <?php $search = "Content Mangement System"; searchForThis($data, $search);?> /></td>
      <td>Corporate Branding</td>
      <td><input type="checkbox" name="chkBranding" value="Corporate Branding" class="blank"
      <?php $search = "Corporate Branding"; searchForThis($data, $search);?> /></td>
    </tr>
    <tr>
      <td>Online Database</td>
      <td><input type="checkbox" name="chkOnlineDB" value="Online Database" class="blank"
      <?php $search = "Online Database"; searchForThis($data, $search);?> /></td>
      <td> </td>
      <td> </td>
    </tr>
  </table>  </td>
</tr>
<tr>
  <td> </td>
  <td colspan="2"> </td>
</tr>
<tr>
  <td><strong>Client Comments:</strong></td>
  <td colspan="2"><input name="txtCommentsTitle" type="text" size="50" value="<?php echo $rsEdit["ClientCommentsTitle"]; ?>" /></td>
</tr>

<tr>
  <td colspan="3"><textarea name="txtComments"  style="width:550px; height:175px;"><?php echo $rsEdit["ClientComments"]; ?></textarea></td>
</tr>
<tr>
<td colspan="3"><div style=" text-align:center">
<input type="submit" name="submit" value="Edit Project" />
<input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/portfolio/index.php'" />
</div></td>
</tr>
</table>
</form>
<?php
}
} else {
$i=0;
$insert_array = array();
  foreach ($_FILES["pictures"]["error"] as $key => $error) {
  $file_name =  $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name
  $file =  $_FILES["pictures"]['tmp_name'][$i];
  $file_size = $_FILES["pictures"]['size'][$i];
  $endresult = "<span style=\"color:#FF0000; font-size:10px;\">$file_name uploaded successfully</span>";
    if ($file_name == "") {
    $pic = $i+1;
    $endresult = "<span style=\"color:#FF0000; font-size:10px;\">Image# $pic Not selected</span>";
    }else{
      if(file_exists("$absolute_path/$file_name")) {
      $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File Already Existed</span>";
      } else {
        if (($size_limit == "yes") && ($limit_size < $file_size)) {
        $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File was to big</span>";
        } else {
        $ext = strrchr($file_name,'.');
          if (($limit_ext == "yes") && (!in_array($ext,$extensions))) {
          $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File is wrong type</span>";
          }else{
          $j = $i + 1;
          $ikey = "NewsImage$j";
          $insert_array[$ikey] = $file_name;
          // first move the file to
          move_uploaded_file($file, $absolute_path.$file_name);
          // Save full size image with max width/height
          resampleimage("400", $absolute_path.$file_name, $absolute_path.$file_name, 0);  // Comment this line out if you don't want to resize the image change the "800" to the size you want
          // Save thumb image with max width/height of 200
          resampleimage("150", $absolute_path.$file_name, $thumb_path.$file_name, 0); // Comment this line out if you don't want to create a thumbnail, change the 200 to the size you want

          }
        }
      }
    }
  $i++;
  echo $endresult."<br>";
  }

//$ext = strrchr($_FILES["pictures"]['name'][$i], ".");
//$n = $i+1;
//$file_name = "file".$n.$ext;

// mysql insert

$PortID = $_POST["txtID"];
$Company = $_POST["txtCompany"];
$Name = $_POST["txtName"];
$URL = $_POST["txtUrl"];
$Location = $_POST["txtLocation"];
$Logo = $_FILES['pictures']['name'][0];
$Image1 = $_FILES['pictures']['name'][1];
$Image2 = $_FILES['pictures']['name'][2];
$Image3 = $_FILES['pictures']['name'][3];
$Case = $_POST["txtCase"];
$Result = $_POST["txtResult"];
$Brief = $_POST["txtBrief"];
$CommentsTitle = $_POST["txtCommentsTitle"];
$Comments = $_POST["txtComments"];
$Date = date("d/m/y");

if (!empty($_POST["chkXHTML"])) {
$Services = ":".$_POST["chkXHTML"].":";}
if (!empty($_POST["chkWebDesign"])) {
$Services = $Services.":".$_POST["chkWebDesign"].":";}
if (!empty($_POST["chkCMS"])) {
$Services = $Services.":".$_POST["chkCMS"].":";}
if (!empty($_POST["chkOnlineDB"])) {
$Services = $Services.":".$_POST["chkOnlineDB"].":";}
if (!empty($_POST["chkPDF"])) {
$Services = $Services.":".$_POST["chkPDF"].":";}
if (!empty($_POST["chkMembership"])) {
$Services = $Services.":".$_POST["chkMembership"].":";}
if (!empty($_POST["chkBranding"])) {
$Services = $Services.":".$_POST["chkBranding"].":";}

$SQL = "UPDATE tblPortfolio Set ClientCompany='$Company', ClientName='$Name', ClientURL='$URL', ClientLocation='$Location', ";

if (!empty($Logo)) {
$SQL = $SQL."ClientLogo='$Logo', ";
}
if (!empty($PortImage1)) {
$SQL = $SQL."PortImage1='$Image1', ";
}
if (!empty($PortImage2)) {
$SQL = $SQL."PortImage2='$Image2', ";
}
if (!empty($PortImage3)) {
$SQL = $SQL."PortImage3='$Image3', ";
}

$SQL = $SQL."ClientCase='$Case', ClientResult='$Result', ClientBrief='$Brief', ClientServices='$Services',  ClientCommentsTitle='$CommentsTitle', ClientComments='$Comments', PortDateEdited='$Date' WHERE PortID='$PortID' ";

mysql_query($SQL) or die(mysql_error());

header("Location: /admin/portfolio/index.php");
}
include($_SERVER['DOCUMENT_ROOT'] . '/includes/logged_footer.php');
?>

heres code from my edit_news.php

 

same principle apart from im doing a few things different in my form above but the code below does almost the same thing and this works...

 

<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');
?>
<div id="subs-container">
<div id="subs">
<div id="subs-admin-text">
<div class="padding">
<ul>
<li class="menu">News Menu:</li>
<li class="menu"><a href="/admin/news/add_news.php">Add</a></li>
<li class="menu"><a href="/admin/news/index.php">Edit</a></li>
<li class="menu"><a href="/admin/news/news_archive.php">Archive</a></li>
<li class="menu"><a href="/news/index.php">View</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="lower-container">
<div id="backlinks"><?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/backlinks.php'); ?></div>
<div id="content">
<div class="padding">
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({xhtml:true}).panelInstance('NewsFull');	
new nicEditor({xhtml:true}).panelInstance('NewsShort');		

});
</script>
<?php

$absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/";//Absolute path to where files are uploaded
$thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/thumbs/";   //Absolute path to where thumbs are to be stored if you want this
$size_limit = "yes";                                          //do you want a size limit yes or no.
$limit_size = "4000000";                                       //How big do you want size limit to be in bytes
$limit_ext = "yes";                                           //do you want to limit the extensions of files uploaded
$ext_count = "4";                                             //total number of extensions in array below
$extensions = array(".jpg", ".jpeg", ".png", ".gif");         //List extensions you want files uploaded to be

function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){
// SET THE IMAGE COMPRESSION
$g_imgcomp=100-$imgcomp;
  // CHECK TO SEE IF THE IMAGE EXISTS FIRST
  if(file_exists($sourcefile)){
  // FIRST WE GET THE CURRENT IMAGE SIZE
  $g_is=getimagesize($sourcefile);
    /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/
    // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE
    if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){
    // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE
    $new_width=$g_is[0];
    $new_height=$g_is[1];
    } else {
    // GET VALUE TO CALCULATE WIDTH AND HEIGHT
    $w_adjust = ($maxsize / $g_is[0]);
    $h_adjust = ($maxsize / $g_is[1]);
      // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT
      if($w_adjust <= $h_adjust){
      // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER
      $new_width=($g_is[0]*$w_adjust);
      $new_height=($g_is[1]*$w_adjust);
      } else {
      // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER
      $new_width=($g_is[0]*$h_adjust);
      $new_height=($g_is[1]*$h_adjust);
      }
    }
  //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." )
$image_type = strrchr($sourcefile, ".");

//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
	case '.jpg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.jpeg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.png':
		$img_src = imagecreatefrompng($sourcefile);
		break;
	case '.gif':
		$img_src = imagecreatefromgif($sourcefile);
		break;
	default:
		echo("Error Invalid Image Type");
		die;
		break;
}
  // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT
  $img_dst=imagecreatetruecolor($new_width,$new_height);
  // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT
  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]);
  // OUTPUT THE IMAGE AS A JPEG.
  // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE.
  imagejpeg($img_dst, $destination, 100);
  // DESTROY THE NEW IMAGE
  imagedestroy($img_dst);
  return true;
  } else {
  return false;
  }
}

if(!isset($_POST['submit'])){
$extens = '';

        if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) {
           $extens = "any extension";
        } else {
        $ext_count2 = $ext_count+1;
        for($counter=0; $counter<$ext_count; $counter++) {
            $extens .= "  $extensions[$counter]";
        }
        }
        if (($limit_size == "") or ($size_limit != "yes")) {
            $limit_size = "any size";
        } else {
            $limit_size .= " bytes";
            $mb_size = ($limit_size/1000000);
        }
        $pichead = "<ul style=\"color:#FF0000; font-size:10px;\"><li>File extension must be $extens</li>";
        $pichead .="<li>Maximum file size is $limit_size ($mb_size MB)</li>
        			<li>No spaces in the filename</li></ul>";
$ID = $_GET["ID"];

$NewsSQL = mysql_query("SELECT * FROM tblNews Where NewsID='".$ID."' ") or die(mysql_error());

while ($rsEdit = mysql_fetch_array($NewsSQL)) {
?>
<h3>Edit News</h3>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" />
<table width="100%">
<tr><td colspan="2">News Images:</td></tr>
<tr><td><table>
<?php
$files = 3;   // Change this line for the number of uploads you want to allow
for($i=1; $i<=$files; $i++){
echo "<tr><td>Image $i :</td><td><input type=\"file\" name=\"pictures[]\" size=\"50\" /></td></tr>\n";
}
?>
<tr>
  <td>Attachment : </td>
  <td><input name="NewsAttachment[]" type="file" id="ufile[]" size="50" /></td>
</tr>
</table></td>
<td><? echo $pichead; ?></td></tr>
<tr>
  <td colspan="2"><?
  echo 'Current Image 1: <a href="/news/uploads/'.$rsEdit["NewsImage1"].'" onclick="window.open(this.href); return false;">'.$rsEdit["NewsImage1"].'</a> | ';
  echo 'Current Image 2: <a href="/news/uploads/'.$rsEdit["NewsImage2"].'" onclick="window.open(this.href); return false;">'.$rsEdit["NewsImage2"].'</a> | ';
  echo 'Current Attachment: <a href="/news/uploads/'.$rsEdit["NewsAttachment"].'" onclick="window.open(this.href); return false;">'.$rsEdit["NewsAttachment"].'</a> | ';
  ?></td>
</tr>
<tr>
  <td colspan="2"><hr /></td>
</tr>
<tr>
  <td colspan="2" style="width:80%;"><span style="width:20%;">News Title: </span></td>
</tr>
<tr>
<td colspan="2" style="width:80%;">
<input type="text" size="45" name="NewsTitle" value="<? echo $rsEdit["NewsTitle"]; ?>" /></td>
</tr>
<tr>
  <td colspan="2"><input type="hidden" name="NewsID" value="<? echo $rsEdit["NewsID"]; ?>" /></td>
</tr>
<tr>
  <td colspan="2">News Brief :</td>
</tr>
<tr>
  <td colspan="2"><textarea name="NewsShort" id="NewsShort" style="width:550px; height:175px;"><? echo $rsEdit["NewsShort"]; ?></textarea></td>
<tr>
  <td colspan="2"> </td>
</tr>
<tr>
  <td colspan="2" >News Full :</td>
</tr>
<tr>
  <td colspan="2"><textarea name="NewsFull" id="NewsFull" style="width:550px; height:175px;"><? echo $rsEdit["NewsFull"]; ?></textarea></td>
  </tr>
<tr>
  <td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"  style="height:32px;"><div style=" text-align:center">
<input type="submit" name=submit value="Edit News" />
<input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/news/index.php'" />
</div></td>
</tr>
</table>
</form>

<?php
}
} else {
$i=0;
$insert_array = array();
  foreach ($_FILES["pictures"]["error"] as $key => $error) {
  $file_name =  $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name
  $file =  $_FILES["pictures"]['tmp_name'][$i];
  $file_size = $_FILES["pictures"]['size'][$i];
  $endresult = "<font size=\"4\" color=990000>$file_name uploaded successfully</font>";
    if ($file_name == "") {
    $pic = $i+1;
    $endresult = "<font size=\"4\" color=990000>Image#$pic Not selected</font>";
    }else{
      if(file_exists("$absolute_path/$file_name")) {
      $endresult = "<font size=\"4\" color=990000>File Already Existed</font>";
      } else {
        if (($size_limit == "yes") && ($limit_size < $file_size)) {
        $endresult = "<font size=\"4\" color=990000>File was to big</font>";
        } else {
        $ext = strrchr($file_name,'.');
          if (($limit_ext == "yes") && (!in_array($ext,$extensions))) {
          $endresult = "<font size=\"4\" color=990000>File is wrong type</font>";
          }else{
          $j = $i + 1;
          $ikey = "NewsImage$j";
          $insert_array[$ikey] = $file_name;
          // first move the file to
          move_uploaded_file($file, $absolute_path.$file_name);
          // Save full size image with max width/height
          resampleimage("800", $absolute_path.$file_name, $absolute_path.$file_name, 0);  // Comment this line out if you don't want to resize the image change the "800" to the size you want
          // Save thumb image with max width/height of 200
          resampleimage("125", $absolute_path.$file_name, $thumb_path.$file_name, 0); // Comment this line out if you don't want to create a thumbnail, change the 200 to the size you want
          }
        }
      }
    }
  $i++;
  echo $endresult."<br>";
  }

//$ext = strrchr($_FILES["pictures"]['name'][$i], ".");
//$n = $i+1;
//$file_name = "file".$n.$ext;

$path1= $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/".$_FILES['NewsAttachment']['name'][0];
move_uploaded_file($_FILES['NewsAttachment']['tmp_name'][0], $path1);
$insert_array['NewsAttachment'] = $_FILES['NewsAttachment']['name'][0];

// mysql insert

$NewsID = $_POST["NewsID"];
$NewsTitle = $_POST["NewsTitle"];
$NewsShort = $_POST["NewsShort"];
$NewsAttach = $_FILES['NewsAttachment']['name'][0];
$NewsImage1 = $_FILES['pictures']['name'][0];
$NewsImage2 = $_FILES['pictures']['name'][1];
$NewsFull = $_POST["NewsFull"];
$NewsDate = date("d/m/y");


$SQL = "UPDATE tblNews Set NewsTitle='$NewsTitle', NewsShort='$NewsShort', ";

if (!empty($NewsImage1)) {
$SQL = $SQL."NewsImage1='$NewsImage1', ";
}
if (!empty($NewsImage2)) {
$SQL = $SQL."NewsImage2='$NewsImage2', ";
}
if (!empty($NewsAttach)) {
$SQL = $SQL."NewsAttachment='$NewsAttach', ";
}

$SQL = $SQL."NewsFull='$NewsFull', NewsDateModified='$NewsDate' WHERE NewsID='$NewsID' ";

mysql_query($SQL) or die(mysql_error());

header("Location: /admin/news/index.php");

}
include($_SERVER['DOCUMENT_ROOT'] . '/includes/logged_footer.php');
?>

from PHP

header() is used to send a raw HTTP  header. See the » HTTP/1.1 specification  for more information on HTTP headers.

 

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

Doesn't make sense that that would work.  In any case, you should fix it there too.  Either use ob_start() at the top and ob_end_flush() at the bottom of the page, or reorganize to something like:

 

if($_POST[submit]) {

//ALL STUFF TO BE DONE IF FORM SUBMITTED, INCLUDING HEADER REDIRECT

}

 

form

ok ive started rearranging well i fully rearranged it and still get the same error, have i not arranged it right now?

 

the form and all the form code are in the default case switch

 

and everything else is in the edit case which comes first, whats wrogn ehre any hints?

 

<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');
?>
<div id="subs-container">
<div id="subs">
<div id="subs-admin-text">
<div class="padding">
<ul>
<li class="menu">Portfolio Menu:</li>
<li class="menu"><a href="/admin/portfolio/add_project.php">Add</a></li>
<li class="menu"><a href="/admin/portfolio/index.php">View/Edit</a></li>
<li class="menu"><a href="/admin/portfolio/current_projects.php">Current Projects</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="lower-container">
<div id="backlinks"><?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/backlinks.php'); ?></div>
<div id="content">
<div class="padding">
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({xhtml:true}).panelInstance('txtCase');	
new nicEditor({xhtml:true}).panelInstance('txtResult');	
new nicEditor({xhtml:true}).panelInstance('txtBrief');	
new nicEditor({xhtml:true}).panelInstance('txtComments');	
});
</script>
<?php
function searchForThis($data, $search){
if (strstr($data, $search)){
	echo 'checked="checked"';}
}
$absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/portfolio/images/";//Absolute path to where files are uploaded
$thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/portfolio/images/thumbs/";   //Absolute path to where thumbs are to be stored if you want this
$size_limit = "yes";                                          //do you want a size limit yes or no.
$limit_size = "4000000";                                       //How big do you want size limit to be in bytes
$limit_ext = "yes";                                           //do you want to limit the extensions of files uploaded
$ext_count = "4";                                             //total number of extensions in array below
$extensions = array(".jpg", ".jpeg", ".png", ".gif");         //List extensions you want files uploaded to be

function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){
// SET THE IMAGE COMPRESSION
$g_imgcomp=100-$imgcomp;
  // CHECK TO SEE IF THE IMAGE EXISTS FIRST
  if(file_exists($sourcefile)){
  // FIRST WE GET THE CURRENT IMAGE SIZE
  $g_is=getimagesize($sourcefile);
    /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/
    // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE
    if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){
    // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE
    $new_width=$g_is[0];
    $new_height=$g_is[1];
    } else {
    // GET VALUE TO CALCULATE WIDTH AND HEIGHT
    $w_adjust = ($maxsize / $g_is[0]);
    $h_adjust = ($maxsize / $g_is[1]);
      // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT
      if($w_adjust <= $h_adjust){
      // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER
      $new_width=($g_is[0]*$w_adjust);
      $new_height=($g_is[1]*$w_adjust);
      } else {
      // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER
      $new_width=($g_is[0]*$h_adjust);
      $new_height=($g_is[1]*$h_adjust);
      }
    }
  //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." )
$image_type = strrchr($sourcefile, ".");

//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
	case '.jpg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.jpeg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.png':
		$img_src = imagecreatefrompng($sourcefile);
		break;
	case '.gif':
		$img_src = imagecreatefromgif($sourcefile);
		break;
	default:
		echo("Error Invalid Image Type");
		die;
		break;
}
  // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT
  $img_dst=imagecreatetruecolor($new_width,$new_height);
  // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT
  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]);
  // OUTPUT THE IMAGE AS A JPEG.
  // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE.
  imagejpeg($img_dst, $destination, 100);
  // DESTROY THE NEW IMAGE
  imagedestroy($img_dst);
  return true;
  } else {
  return false;
  }
}

switch(@$_GET["action"]) {
Case "edit":
$i=0;
$insert_array = array();
  foreach ($_FILES["pictures"]["error"] as $key => $error) {
  $file_name =  $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name
  $file =  $_FILES["pictures"]['tmp_name'][$i];
  $file_size = $_FILES["pictures"]['size'][$i];
  $endresult = "<span style=\"color:#FF0000; font-size:10px;\">$file_name uploaded successfully</span>";
    if ($file_name == "") {
    $pic = $i+1;
    $endresult = "<span style=\"color:#FF0000; font-size:10px;\">Image# $pic Not selected</span>";
    }else{
      if(file_exists("$absolute_path/$file_name")) {
      $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File Already Existed</span>";
      } else {
        if (($size_limit == "yes") && ($limit_size < $file_size)) {
        $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File was to big</span>";
        } else {
        $ext = strrchr($file_name,'.');
          if (($limit_ext == "yes") && (!in_array($ext,$extensions))) {
          $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File is wrong type</span>";
          }else{
          $j = $i + 1;
          $ikey = "NewsImage$j";
          $insert_array[$ikey] = $file_name;
          // first move the file to
          move_uploaded_file($file, $absolute_path.$file_name);
          // Save full size image with max width/height
          resampleimage("400", $absolute_path.$file_name, $absolute_path.$file_name, 0);  // Comment this line out if you don't want to resize the image change the "800" to the size you want
          // Save thumb image with max width/height of 200
          resampleimage("150", $absolute_path.$file_name, $thumb_path.$file_name, 0); // Comment this line out if you don't want to create a thumbnail, change the 200 to the size you want

          }
        }
      }
    }
  $i++;
  echo $endresult."<br>";
  }
// mysql insert

$PortID = $_POST["txtID"];
$Company = $_POST["txtCompany"];
$Name = $_POST["txtName"];
$URL = $_POST["txtUrl"];
$Location = $_POST["txtLocation"];
$Logo = $_FILES['pictures']['name'][0];
$Image1 = $_FILES['pictures']['name'][1];
$Image2 = $_FILES['pictures']['name'][2];
$Image3 = $_FILES['pictures']['name'][3];
$Case = $_POST["txtCase"];
$Result = $_POST["txtResult"];
$Brief = $_POST["txtBrief"];
$CommentsTitle = $_POST["txtCommentsTitle"];
$Comments = $_POST["txtComments"];
$Date = date("d/m/y");

if (!empty($_POST["chkXHTML"])) {
$Services = ":".$_POST["chkXHTML"].":";}
if (!empty($_POST["chkWebDesign"])) {
$Services = $Services.":".$_POST["chkWebDesign"].":";}
if (!empty($_POST["chkCMS"])) {
$Services = $Services.":".$_POST["chkCMS"].":";}
if (!empty($_POST["chkOnlineDB"])) {
$Services = $Services.":".$_POST["chkOnlineDB"].":";}
if (!empty($_POST["chkPDF"])) {
$Services = $Services.":".$_POST["chkPDF"].":";}
if (!empty($_POST["chkMembership"])) {
$Services = $Services.":".$_POST["chkMembership"].":";}
if (!empty($_POST["chkBranding"])) {
$Services = $Services.":".$_POST["chkBranding"].":";}

$SQL = "UPDATE tblPortfolio Set ClientCompany='$Company', ClientName='$Name', ClientUrl='$URL', ClientLocation='$Location', ";

if (!empty($Logo)) {
$SQL = $SQL."ClientLogo='$Logo', ";
}
if (!empty($PortImage1)) {
$SQL = $SQL."PortImage1='$Image1', ";
}
if (!empty($PortImage2)) {
$SQL = $SQL."PortImage2='$Image2', ";
}
if (!empty($PortImage3)) {
$SQL = $SQL."PortImage3='$Image3', ";
}

$SQL = $SQL."ClientCase='$Case', ClientResult='$Result', ClientBrief='$Brief', ClientServices='$Services',  ClientCommentsTitle='$CommentsTitle', ClientComments='$Comments', PortDateEdited='$Date' WHERE PortID='$PortID' ";

mysql_query($SQL) or die(mysql_error());

header("Location: /admin/portfolio/index.php");
break;

default:
$extens = '';

        if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) {
           $extens = "any extension";
        } else {
        $ext_count2 = $ext_count+1;
        for($counter=0; $counter<$ext_count; $counter++) {
            $extens .= "  $extensions[$counter]";
        }
        }
        if (($limit_size == "") or ($size_limit != "yes")) {
            $limit_size = "any size";
        } else {
            $limit_size .= " bytes";
            $mb_size = ($limit_size/1000000);
        }
        $pichead = "<ul style=\"color:#FF0000; font-size:10px;\"><li style=\"display:inline; padding-right:10px;\">File extension must be $extens |</li>";
        $pichead .="<li style=\"display:inline; padding-right:10px;\">Maximum file size is $limit_size ($mb_size MB) |</li>
        			<li style=\"display:inline; padding-right:10px;\">No spaces in the filename</li></ul>";

$ID = $_GET["ID"];

$PortSQL = mysql_query("SELECT * FROM tblPortfolio WHERE PortID='$ID' ") or die(mysql_error());

while ($rsEdit = mysql_fetch_array($PortSQL)) {
?>
<h3>Edit Project</h3>
<form action="<?=$_SERVER['PHP_SELF']?>?action=edit" method="post" enctype="multipart/form-data" />
<input name="txtID" type="hidden"  value="<?php echo $rsEdit["PortID"]; ?>" />
<table width="100%">
<tr>
  <td><strong>Company Name:</strong></td>
  <td colspan="2"><input name="txtCompany" type="text" size="50" value="<?php echo $rsEdit["ClientCompany"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Client Name</strong></td>
  <td colspan="2"><input name="txtName" type="text" id="txtName" size="50" value="<?php echo $rsEdit["ClientName"]; ?>" /></td>
</tr>


<tr>
  <td><strong>Client Location</strong></td>
  <td colspan="2"><input name="txtLocation" type="text" id="txtLocation" size="50" value="<?php echo $rsEdit["ClientLocation"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Url:</strong></td>
  <td colspan="2"><input name="txtUrl" type="text" size="70" value="<?php echo $rsEdit["ClientUrl"]; ?>" /></td>
</tr>
<tr>
  <td><strong>Client Logo:</strong></td>
  <td><input type="file" name="pictures[]" size="50" /></td><td rowspan="3"><? echo $pichead; ?></td></tr>
<tr><td><strong>Image 1:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr><td><strong>Image 2:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr><td><strong>Image 3:</strong></td><td><input type="file" name="pictures[]" size="50" /></td></tr>
<tr>
  <td colspan="3"><strong>Client Brief / About the Client:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtBrief" style="width:550px; height:175px;"><?php echo $rsEdit["ClientBrief"]; ?></textarea></td>
<tr>
<tr>
  <td colspan="3"><strong>What the client wanted:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtCase" style="width:550px; height:175px;"><?php echo $rsEdit["ClientCase"]; ?></textarea></td>
<tr>
  <td colspan="3"><strong>Case result:</strong></td>
</tr>
<tr>
  <td colspan="3"><textarea name="txtResult" style="width:550px; height:175px;"><?php echo $rsEdit["ClientResult"]; ?></textarea></td>
<tr>
  <td colspan="3"><strong>Client Services</strong></td>
<tr>
  <td colspan="3">
<?php $data = $rsEdit["ClientServices"]; ?>
  <table width="50%" border="0">
    <tr>
      <td>XHTML/CSS Standards Compliant</td>
      <td><input type="checkbox" name="chkXHTML" value="XHTML/CSS Standards Compliant" class="blank"
       <?php $search = "XHTML/CSS Standards Compliant"; searchForThis($data, $search);?> /></td>
      <td>Form to PDF/Email</td>
      <td><input type="checkbox" name="chkPDF" value="Form to PDF/Email" class="blank"
      <?php $search = "Form to PDF/Email"; searchForThis($data, $search);?>  /></td>
    </tr>
    <tr>
      <td>Webpage Design</td>
      <td><input type="checkbox" name="chkWebDesign" value="Webpage Design" class="blank" id="chkWebDesign"
      <?php $search = "Webpage Design"; searchForThis($data, $search);?> /></td>
      <td>Membership System</td>
      <td><input type="checkbox" name="chkMembership" value="Membership System" class="blank"
      <?php $search = "Membership System"; searchForThis($data, $search);?> /></td>
    </tr>
    <tr>
      <td>Content Management System</td>
      <td><input type="checkbox" name="chkCMS" value="Content Mangement System" class="blank"
      <?php $search = "Content Mangement System"; searchForThis($data, $search);?> /></td>
      <td>Corporate Branding</td>
      <td><input type="checkbox" name="chkBranding" value="Corporate Branding" class="blank"
      <?php $search = "Corporate Branding"; searchForThis($data, $search);?> /></td>
    </tr>
    <tr>
      <td>Online Database</td>
      <td><input type="checkbox" name="chkOnlineDB" value="Online Database" class="blank"
      <?php $search = "Online Database"; searchForThis($data, $search);?> /></td>
      <td> </td>
      <td> </td>
    </tr>
  </table>  </td>
</tr>
<tr>
  <td> </td>
  <td colspan="2"> </td>
</tr>
<tr>
  <td><strong>Client Comments:</strong></td>
  <td colspan="2"><input name="txtCommentsTitle" type="text" size="50" value="<?php echo $rsEdit["ClientCommentsTitle"]; ?>" /></td>
</tr>

<tr>
  <td colspan="3"><textarea name="txtComments"  style="width:550px; height:175px;"><?php echo $rsEdit["ClientComments"]; ?></textarea></td>
</tr>
<tr>
<td colspan="3"><div style=" text-align:center">
<input type="submit" name="submit" value="Edit Project" />
<input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/portfolio/index.php'" />
</div></td>
</tr>
</table>
</form>
<?php
}
break;
}
include($_SERVER['DOCUMENT_ROOT'] . '/includes/logged_footer.php');
?>

i know its something going on here now

 

  foreach ($_FILES["pictures"]["error"] as $key => $error) {
  $file_name =  $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name
  $file =  $_FILES["pictures"]['tmp_name'][$i];
  $file_size = $_FILES["pictures"]['size'][$i];
  $endresult = "<span style=\"color:#FF0000; font-size:10px;\">$file_name uploaded successfully</span>";
    if ($file_name == "") {
    $pic = $i+1;
    $endresult = "<span style=\"color:#FF0000; font-size:10px;\">Image# $pic Not selected</span>";
    }else{
      if(file_exists("$absolute_path/$file_name")) {
      $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File Already Existed</span>";
      } else {
        if (($size_limit == "yes") && ($limit_size < $file_size)) {
        $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File was to big</span>";
        } else {
        $ext = strrchr($file_name,'.');
          if (($limit_ext == "yes") && (!in_array($ext,$extensions))) {
          $endresult = "<span style=\"color:#FF0000; font-size:10px;\">File is wrong type</span>";
          }else{
          $j = $i + 1;
          // first move the file to
          move_uploaded_file($file, $absolute_path.$file_name);
          // Save full size image with max width/height
          resampleimage("175", $absolute_path.$file_name, $absolute_path.$file_name, 0);  // Comment this line out if you don't want to resize the image change the "800" to the size you want
          // Save thumb image with max width/height of 200
          resampleimage("150", $absolute_path.$file_name, $thumb_path.$file_name, 0); // Comment this line out if you don't want to create a thumbnail, change the 200 to the size you want
          }
        }
      }
    }
  $i++;
  echo $endresult."<br>";
  }

 

ive taken out the echo endresult line then the page just loads blank i put it back in but changed the image pic not slected variable to the header code so if no image was slected the paeg would relcoate, this doesnt work

ive taken out that whole if statement too

so it just goes from teh for each statement, uploads then redirects loads a blank page again...

Ok, you are not understanding what is meant.  YOU CAN'T OUTPUT ANYTHING TO THE BROWSER.  That means any code that will show up on your outputted php page.  I am pretty positive that includes/header has some and <div id="subs-container"> is already outputting.  Here is an example:

 

<?
if ($_POST['submit']) {
header("Location: http://www.".$_POST[domain]);
}
include ('includes/header.php');
?>
<form enctype="multipart/form-data" action="" method="post">
<div class="formleft">Domain:</div>
<div class="formright"><input type="text" name="domain" value="" size="50" /></div> 
<div class="formleft"> </div>
<div class="formright"><input type="submit" alt="Submit" name="submit" id="submit" value="Submit" /></div>
</form>
<? 
include('includes/footer.php');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.