<?php
include('../TT_inc.php');
//if they are trying to set the photo then do this stuff, otherwise do other stuff
if (strlen($_FILES['photo']['name']) > 0)
{
$target = "specials/";
$target = $target . $_FILES['photo']['name'];
//upload the photo
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
echo "The file ". $_FILES['photo']['name'] . " has been uploaded.";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
//set query that updates the photo field
$sql = "UPDATE specials SET tagline='". $tagline ."', summary='". $summary ."', category='". $category ."', date='". $date ."', details='". $details ."', email='". $email ."', photo='". $_FILES['photo']['name'] ."', frontpage='". $_POST[frontpage] ."' WHERE specialID='".$specialID."'";
}
else
{
//set query that DOES NOT update the photo field
$sql = "UPDATE specials SET tagline='". $tagline ."', summary='". $summary ."', category='". $category ."', date='". $date ."', details='". $details ."', email='". $email ."', frontpage='". $_POST[frontpage] ."' WHERE specialID='".$specialID."'";
}
//execute query that may or may not update the photo field
if (!mysql_query($sql,$mysql_link))
{
die('Error: ' . mysql_error());
}
else
{
header("Location: travel_specials.php");
}
?>
Does that help? Figured it would be easier to just give u the code than try to explain it.