Hallo,
hieronder staat mijn script. Het werkt wel indien geen plaatje wordt toegevoegd. Als de gebruiker een plaatje toevoegd werkt het echter niet. Iemand enig idee?
alvast bedankt!
<?
if (isset($_POST['add'])) //kijken of er iets meekomt met URL
{
if (isset($_POST['title']) && $_POST['catalogue_number'] && $_POST['price'] && $_POST['shipping_costs'] && $_POST['description'] && $_POST['condition'])
{
$title = htmlentities($_POST['title']);
$title = ucfirst($title);
$cat = htmlentities($_POST['catalogue_number']);
$cat = ucfirst($cat);
$price = htmlentities($_POST['price']);
$shipping = htmlentities($_POST['shipping_costs']);
$description = htmlentities($_POST['description']);
if (!($_FILES['file']['name']))
{
$filename=TRUE;
unset ($filename);
}
else
{
$filename = $_FILES['file']['name'];
}
if (check_length($title, 15))
{
echo "Title field has to be at least 15 characters<br><a href=\"#\" onclick=\"history.go(-1)\">back</a></script>";
}
elseif (check_length($description, 75))
{
echo "Description field has to be at least 75 characters<br><a href=\"#\" onclick=\"history.go(-1)\">back</a></script>";
}
elseif (!is_numeric($price))
{
echo "Please enter your price in numbers: 29,95 is valid. Every input with letters is false";
}
elseif (!is_numeric($shipping))
{
echo "Please enter the shipping costs in numbers: 29,95 is valid. Every input with letters is false";
}
elseif(isset($filename))
{
$size = $_FILES['file']['size'];
$extensie = substr($filename, -3);
if (strtoupper($extensie) != "JPG" && strtoupper($extensie) != "GIF" && strtoupper($extensie) != "JPEG")
{
echo "Only JPG or GIF files can be used!<br><script><a href=\"#\" onclick=\"history.go(-1)\">back</a>')</script>";
}
elseif ($size > 51200)
{
echo "Only JPG, JPEG or GIF files can be used!<br><script><a href=\"#\" onclick=\"history.go(-1)\">back</a>')</script>";
}
}
// plaats het oproepje
elseif (isset($_POST['add']))
{
if (isset($filename))
{
$filename = $_FILES['file']['name'];
$destination = "/home/tineau/public_html/images/ad_images/";
$length = strlen($filename);
$name = "ad_images";
// $name = substr($filename, 0, $length - 4);
$i = 0;
$tempname = $name;
// Check of file al bestaat, zo ja, filename 'verhogen'
while (file_exists($destination . $tempname . $i . ".".$extensie))
{
$i = $i + 1;
}
$name = $name . $i;
move_uploaded_file($file, $destination . $name . ".".$extensie);
$bestand="$name"."."."$extensie";
}
else
{
$bestand='';
}
$description = parse1($description);
$datum = date("D M j G:i:s T Y");
$sql = "insert into sell_list (sell_id, login, title, catalogue_number, price, shipping_cost, description, condition, image_path, date) VALUES ('', '$_SESSION[login]', '$title', '$cat', '$price', '$shipping', '$description', '$_POST[condition]', '$bestand', '$datum')";
$res = mysql_query($sql);
if ($res)
{
echo"Succes";
}
else
{
echo"Failure";
}
}
}
else
{
echo "You have not completely filled in all fields,<br> Go back and try again!<br><a href=\"#\" onclick=\"history.go(-1)\">back</a></script>";
}
}
?>
1.128 views