<?php
// establish db connection
$sql_link = mysql_connect("mysqlhost", "u70262984", "xxxxxx");
mysql_select_db("d60244618");


if ($_FILES['userfile']['type'] == "image/gif") {
    header("Location: http://www.alamotrades.com/gif.html");
} else {





if ($typeofitem!="" && $description!="" && $yourname!="" && $email!="" && $phone!="") {

    $month = date("m");
    $day = date("d");
    $year = date("Y");

    if ($month == "12") {
        $month = "1";
        $year = $year + 1;
    } else {
        $month = $month + 1;
    }

    $theexpdate = $year . "-" . $month . "-" . $day;

    if ($_FILES['userfile']['tmp_name'] != "") {
        require("php-lib/imageupload.php");

	    uploadtheimg($_FILES['userfile']['tmp_name'], "/export/home/vonoventwin/public_html/images/content/", 900, 900, $month . $day . $year . $_FILES['userfile']['name']);
    }

    mysql_query("REPLACE content SET id='" . $id . "'," .
    			"typeofitem='" . $typeofitem . "'," .
    			"description='" . $description . "'," .
    			"yourname='" . $yourname . "'," .
    			"email='" . $email . "'," .
    			"phone='" . $phone . "'," .
    			"active='0'," .
    			"exp_date='" . $theexpdate . "'," .
    			"photo='" . $month . $day . $year . $_FILES['userfile']['name'] . "';");


if ($id!="") {
    $theid == $id;
} else {
    $theid = mysql_insert_id();
}






$themsg ="

A new item has been submitted! <br><br>

<a href='http://www.alamotrades.com/php-lib/approve.php?id=$theid'>Click here to approve this item</a>


<Br><br>
Item Info:
<br>
    			Type of Item= $typeofitem<br>
    			Name= $yourname<br>
    			Phone= $phone<br>
    			E-Mail= $email<br>
    			Description= $description<br>


";

if ($imgsrc_name != "") {
  $themsg .= "Image Name= " . $month . $day . $year . $_FILES['userfile']['name'] . "<br> \n Image: <br> <img src=\"http://www.alamotrades.com/images/content/" . $month . $day . $year . $_FILES['userfile']['name'] . "\">";
}

    mail("sales@alamotrades.com", "NEW ITEM ON alamotrades.com", $themsg, "From: newitem@alamotrades.com\nContent-Type: text/html");

    ///////////////////////////////////////////////////////////////////
    //////////////////////  THIS IS WHERE YOU PUT THE PAYPAL ADDRESS
    header("Location: http://www.alamotrades.com/thanks2.html");
    ///////////////////////////////////////////////////////////////////

} else {

    header("Location: http://www.alamotrades.com/error.html");
}

}


?>