Assistance with if..elseif statement
| From: | Craig Hoffman | Date: | Mon, 17 Jan 2005 14:21:55 +0000 |
| Subject: | Assistance with if..elseif statement | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-38174@lists.php.net to get a copy of this message | ||
I have this block of code which checks to see if an image has been uploaded from an update form. Everything in the form works, except I can not get the the elseif statements to behave properly. See the comments below for explanation. Any help would be appreciated.
$route_photo = $_FILES['image']['name'];
// if no new image and no existing image put NULL in the DB
if(empty($_FILES['image']['name']) && ($_POST['oldimage']) == '')
{
$route_photo = 'NULL';
echo ("No image supplied.");
// if new image put the new image name in the DB
} elseif ($_POST['route_photo'] || $_FILES['image']['name']) {
$route_photo = $_POST['route_photo'];
echo ("The image has been replaced with $route_photo.");
// If no new image update, use the old image
} elseif ($_POST['route_photo'] = $_POST['oldimage'])
{
$route_photo = $_POST['oldimage'];
echo("No new image supplied");
}