Viewing file: upload_property.php (7.71 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
/*
this script takes the form data collected from the new property
or modify property form and inserts it into the database
*/
include ("../include/settings");
include ("../include/db_connect");
include ("resize.php");
// DO THIS IF IT IS A NEW LISTING
if ($delete == "yes")
{
$deleted = mysql_query("DELETE FROM listings WHERE ID = "."'$ID'", $db);
if ($deleted)
{
print("<p align=\"center\"><br><br><b>Property Deleted.</b><br><br>\n");
include ("index.php");
}
}
else{
if ($modify != "yes")
{
$new_row = mysql_query("INSERT INTO listings (ID)
values (NULL)", $db);
//Get auto-increment ID value
$ID_data = mysql_query("SELECT LAST_INSERT_ID()", $db);
$ID = mysql_result($ID_data, 0, 'last_insert_ID()');
}
$query = "UPDATE listings SET title = '$title'";
// Prepare query
$query .= ", active = '$active', type = '$type'";
if (($area) and ($area != "none"))
{
$query .= ", area = '$area'";
}
if ($vtour == "on") $vtour = "yes";
else $vtour = "no";
$query .= ", vtour = '$vtour'";
if ($vtourURL != "none")
{
$query .= ", vtourURL = '$vtourURL'";
}
$query .= ", intro = '$intro'";
$query .= ", description = '$description'";
$query .= ", asking = '$asking', show_asking = '$show_asking'";
$query .= ", selling = '$selling', show_selling = '$show_selling'";
$query .= ", price = '$price', show_price = '$show_price'";
if (($month) and ($month != "none"))
{
$query .= ", month = '$month'";
}
if (($year) and ($year != "none"))
{
$query .= ", year = '$year', show_date = '$show_date'";
}
//-----thumbnail---------------------------
if (($thumb) and ($thumb != "none"))
{
//make a unique image name based on reference name
$thumb_reference = "thumbnail_$ID.jpg";
//transfer file
if(copy($thumb, "../property_pics/$thumb_reference"))
{
$query .= ", thumb = '$thumb_reference'";
resize("../property_pics/$thumb_reference", "../property_pics/$thumb_reference", $imag_size['prop_thumb'][0], $imag_size['prop_thumb'][1]);
}
else
{
print("error transferring thumbnail <br>\n");
}
}
//-----main picture---------------------------
if (($main_pic) and ($main_pic != "none"))
{
//make a unique image name based on reference name
$main_pic_reference = "main_pic_$ID.jpg";
//transfer file
if(copy($main_pic, "../property_pics/$main_pic_reference"))
{
$query .= ", main_pic = '$main_pic_reference'";
resize("../property_pics/$main_pic_reference", "../property_pics/$main_pic_reference", $imag_size['prop_main'][0], $imag_size['prop_main'][1]);
}
else
{
print("error transferring main_pic<br>\n");
}
}
//-----picture 1---------------------------
if (($picture1) and ($picture1 != "none"))
{
//make a unique image name based on reference name
$picture1_reference = "picture1_$ID.jpg";
//transfer file
if(copy($picture1, "../property_pics/$picture1_reference"))
{
$query .= ", picture1 = '$picture1_reference'";
resize("../property_pics/$picture1_reference", "../property_pics/$picture1_reference", $imag_size['prop_secondary'][0], $imag_size['prop_secondary'][1]);
}
else
{
print("error transferring picture number 1<br>\n");
}
}
//-----picture 2---------------------------
if (($picture2) and ($picture2 != "none"))
{
//make a unique image name based on reference name
$picture2_reference = "picture2_$ID.jpg";
//transfer file
if(copy($picture2, "../property_pics/$picture2_reference"))
{
$query .= ", picture2 = '$picture2_reference'";
resize("../property_pics/$picture2_reference", "../property_pics/$picture2_reference", $imag_size['prop_secondary'][0], $imag_size['prop_secondary'][1]);
}
else
{
print("error transferring picture number 2<br>\n");
}
}
//-----picture3---------------------------
if (($picture3) and ($picture3 != "none"))
{
//make a unique image name based on reference name
$picture3_reference = "picture3_$ID.jpg";
//transfer file
if(copy($picture3, "../property_pics/$picture3_reference"))
{
$query .= ", picture3 = '$picture3_reference'";
resize("../property_pics/$picture3_reference", "../property_pics/$picture3_reference", $imag_size['prop_secondary'][0], $imag_size['prop_secondary'][1]);
}
else
{
print("error transferring picture number 3<br>\n");
}
}
//-----picture 4---------------------------
if (($picture4) and ($picture4 != "none"))
{
//make a unique image name based on reference name
$picture4_reference = "picture4_$ID.jpg";
//transfer file
if(copy($picture4, "../property_pics/$picture4_reference"))
{
$query .= ", picture4 = '$picture4_reference'";
resize("../property_pics/$picture4_reference", "../property_pics/$picture4_reference", $imag_size['prop_secondary'][0], $imag_size['prop_secondary'][1]);
}
else
{
print("error transferring picture number 4<br>\n");
}
}
//-----picture 5---------------------------
if (($picture5) and ($picture5 != "none"))
{
//make a unique image name based on reference name
$picture5_reference = "picture5_$ID.jpg";
//transfer file
if(copy($picture5, "../property_pics/$picture5_reference"))
{
$query .= ", picture5 = '$picture5_reference'";
resize("../property_pics/$picture5_reference", "../property_pics/$picture5_reference", $imag_size['prop_secondary'][0], $imag_size['prop_secondary'][1]);
}
else
{
print("error transferring picture number 5<br>\n");
}
}
//-----picture 6---------------------------
if (($picture6) and ($picture6 != "none"))
{
//make a unique image name based on reference name
$picture6_reference = "picture6_$ID.jpg";
//transfer file
if(copy($picture6, "../property_pics/$picture6_reference"))
{
$query .= ", picture6 = '$picture6_reference'";
resize("../property_pics/$picture5_reference", "../property_pics/$picture5_reference", $imag_size['prop_secondary'][0], $imag_size['prop_secondary'][1]);
}
else
{
print("error transferring picture number 6<br>\n");
}
}
$query .= ", caption1 = '$caption1',
caption2 = '$caption2',
caption3 = '$caption3',
caption4 = '$caption4',
caption5 = '$caption5',
caption6 = '$caption6'";
//bullets
$query .= ", bullet1 = '$bullet1',
bullet2 = '$bullet2',
bullet3 = '$bullet3',
bullet4 = '$bullet4',
bullet5 = '$bullet5',
bullet6 = '$bullet6',
bullet7 = '$bullet7',
bullet8 = '$bullet8'";
$query .= " WHERE ID = '$ID'";
$upload = mysql_query("$query", $db);
//Delete this?
if ($upload)
{
print("<p align=\"center\"><br><br><b>Upload successful!</b><br><br>\n");
include ("index.php");
}
else
{
print("<p align=\"center\"><br><br><b>OOPS, something went wrong. Try it again.</b><br>If you still have problems, please notify Dan Psomas Web Design<br>by <a href=\"mailto:dan@danpsomas.com?subject=Problems uploading\">e-mail</a> or phone: (510) 865-0273<br>\n<a href=\"index.php\">Go back to admin menu</a>");
}
}
?>
|