youthBYTES
11-01-2006, 11:11 AM
i know this is something people commonly ask and there is plenty of examples, but i don't know WHY but its not working for me, help?
$posttime = time();
$type = trim($_POST['type']);
$title = trim($_POST['title']);
$details = addslashes(trim($_POST['details']));
$filecount = $_POST['filecount'];
$result = $DB->query("SELECT * FROM `portfolio` WHERE type='$type' AND title='$title'");
if($row = mysql_fetch_array($result))
{
$exists = 'yes';
}
// Verification
if (cms_isEmpty($title) == false || cms_isEmpty($details) == false || cms_isEmpty($exists))
{
$submitdetails = $DB->query("INSERT INTO `portfolio` (`date`,`type`, `title`, `details`) VALUES ('$posttime','$type','$title','$details')");
$uploaddir = '../images/' . $type . '/';
for ($i =0; $i<$filecount; $i++)
{
$filename = $_FILES['file']['name'][$i];
$filetmp = $_FILES['file']['tmp_name'][$i];
$filepath = $uploaddir . $filename;
$dbname = 'image' . ($i+1);
if ($filename != "")
{
if (!file_exists($filepath))
{
$upload = move_uploaded_file($filetmp, $filepath);
$submitimages = $DB->query("UPDATE portfolio SET $dbname='$filename' WHERE title='$title'");
echo $filename . ' <i>uploaded sucessfully...</i><br />';
}
else
{
echo $filename . ' <i>already exists...</i><br />';
}
}
}
cms_redirect('index.php','Your new portfolio work was successfully entered into the database!<br />You will now be taken to the main administration page.');
}
else
{
if (cms_isEmpty($title))
{
cms_msgBox('You need a title');
$action = 'add';
}
if (cms_isEmpty($details))
{
cms_msgBox('You need details');
$action = 'add';
}
if (cms_isEmpty($exists) == false)
{
cms_msgBox('Portfolio already exists');
$action = 'add';
}
}
$posttime = time();
$type = trim($_POST['type']);
$title = trim($_POST['title']);
$details = addslashes(trim($_POST['details']));
$filecount = $_POST['filecount'];
$result = $DB->query("SELECT * FROM `portfolio` WHERE type='$type' AND title='$title'");
if($row = mysql_fetch_array($result))
{
$exists = 'yes';
}
// Verification
if (cms_isEmpty($title) == false || cms_isEmpty($details) == false || cms_isEmpty($exists))
{
$submitdetails = $DB->query("INSERT INTO `portfolio` (`date`,`type`, `title`, `details`) VALUES ('$posttime','$type','$title','$details')");
$uploaddir = '../images/' . $type . '/';
for ($i =0; $i<$filecount; $i++)
{
$filename = $_FILES['file']['name'][$i];
$filetmp = $_FILES['file']['tmp_name'][$i];
$filepath = $uploaddir . $filename;
$dbname = 'image' . ($i+1);
if ($filename != "")
{
if (!file_exists($filepath))
{
$upload = move_uploaded_file($filetmp, $filepath);
$submitimages = $DB->query("UPDATE portfolio SET $dbname='$filename' WHERE title='$title'");
echo $filename . ' <i>uploaded sucessfully...</i><br />';
}
else
{
echo $filename . ' <i>already exists...</i><br />';
}
}
}
cms_redirect('index.php','Your new portfolio work was successfully entered into the database!<br />You will now be taken to the main administration page.');
}
else
{
if (cms_isEmpty($title))
{
cms_msgBox('You need a title');
$action = 'add';
}
if (cms_isEmpty($details))
{
cms_msgBox('You need details');
$action = 'add';
}
if (cms_isEmpty($exists) == false)
{
cms_msgBox('Portfolio already exists');
$action = 'add';
}
}