I am terribly sorry, I pasted the wrong page. This is the page that lets him add new cars to the DB. As for what ive tried so far. I was trying to follow the phpacademy tutorial on the topic, but was unable to actually make it apply here, as I am still not quite that good at this yet. and was also pointed to this link http://www.9lessons.info/2009/03/upload-and-resize-image-with-php.html, but again, was unable to make that apply to what I have already written. So any advice or direction would be greatly appreciated sir.
[php]<?php
include ‘core/init.php’;
protect_page();
include ‘includes/overall/overallheader.php’;
include(‘connection.php’);
?>
<?php include 'includes/admin_menu.php'; ?>
<?php
if (isset($_POST['submit'])) {
echo "
Vehicle Successfully Added!
";
}
?>
Add New Vehicle
Vehicle Images
Interior Front:
|
Interior Rear:
|
<?php
if(isset($_POST['submit']))
{
if(is_uploaded_file($_FILES['front']['tmp_name']))
{
$name = $_FILES['front']['name'];
$tmp_name = $_FILES['front']['tmp_name'];
$location = "front/$name";
move_uploaded_file($tmp_name,$location);
}
else{$location = 'front/default.jpg';}
if(is_uploaded_file($_FILES['rear']['tmp_name']))
{
$name = $_FILES['rear']['name'];
$tmp_name = $_FILES['rear']['tmp_name'];
$location2 = "rear/$name";
move_uploaded_file($tmp_name,$location2);
}
else{$location2 = 'rear/default.jpg';}
if(is_uploaded_file($_FILES['left']['tmp_name']))
{
$name = $_FILES['left']['name'];
$tmp_name = $_FILES['left']['tmp_name'];
$location3 = "left/$name";
move_uploaded_file($tmp_name,$location3);
}
else{$location3 = 'left/default.jpg';}
if(is_uploaded_file($_FILES['right']['tmp_name']))
{
$name = $_FILES['right']['name'];
$tmp_name = $_FILES['right']['tmp_name'];
$location4 = "right/$name";
move_uploaded_file($tmp_name,$location4);
}
else{$location4 = 'righ/defautlt.jpg';}
if(is_uploaded_file($_FILES['intfront']['tmp_name']))
{
$name = $_FILES['intfront']['name'];
$tmp_name = $_FILES['intfront']['tmp_name'];
$location5 = "intfront/$name";
move_uploaded_file($tmp_name,$location5);
}
else{$location5 = 'intfront/defautlt.jpg';}
if(is_uploaded_file($_FILES['intrear']['tmp_name']))
{
$name = $_FILES['intrear']['name'];
$tmp_name = $_FILES['intrear']['tmp_name'];
$location6 = "intrear/$name";
move_uploaded_file($tmp_name,$location6);
}
else{$location6 = 'intrear/defautlt.jpg';}
$_year = mysql_real_escape_string($_POST['year']);
$_make = mysql_real_escape_string($_POST['make']);
$_model = mysql_real_escape_string($_POST['model']);
$_style = mysql_real_escape_string($_POST['style']);
$_mileage = mysql_real_escape_string($_POST['mileage']);
$_color = mysql_real_escape_string($_POST['color']);
$_rprice = mysql_real_escape_string($_POST['rprice']);
$sql="INSERT INTO `veh` SET `year`='$_year',
`make`='$_make',
`model`='$_model',
`style`='$_style',
`mileage`='$_mileage',
`color`='$_color',
`rprice`='$_rprice',
`front`='$location',
`rear`='$location2',
`left`='$location3',
`right`='$location4',
`intfront`='$location5',
`intrear`='$location6'";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
}
?>
<?php include 'includes/overall/overallfooter.php'; ?>[/php]