Ok, I have a form that uploads the users image to a folder on my site and also emails me the new image. I would like this form to also save the final images destination and name into my sql database. The row that the image should save too in the database is called: Banner Location and is varachar 100. How can I get this to work? I have attached my coding below.
Any Help would be appreciated...🙂
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "banner")) {
$insertSQL = sprintf("INSERT INTO banneradvertising (`Full Name`, `Email Address`, `Banner Run Time`, `Banner Location`) VALUES (%s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['Name'], "text"),
GetSQLValueString($HTTP_POST_VARS['Email'], "text"),
GetSQLValueString($HTTP_POST_VARS['Time'], "text"),
GetSQLValueString($HTTP_POST_VARS['SendFile'], "text"));
mysql_select_db($database_gspot, $gspot);
$Result1 = mysql_query($insertSQL, $gspot) or die(mysql_error());
}
// Check to see if the form has been posted
if (isset($_POST['SendFile']))
{
// Set the Array of acceptable FileTypes
$FileTypes=array( "image/cGif" , "image/gif" , "image/cJpeg" , "image/pjpeg" );
// Check to ensure the uploaded file is of correct type
if (in_array($_FILES['UPLDoc']['type'],$FileTypes))
{
// Set the upload directory
$UploadDir = '/img/sponsors/uploaded/';
// Move the file
move_uploaded_file($_FILES['UPLDoc']['tmp_name'], $UploadDir . $_FILES['UPLDoc']['name']);
// Open the file and read the contents into a string
$FileName=$UploadDir.$_FILES['UPLDoc']['name'];
$FilePointer=fopen($FileName, "r");
$File=fread($FilePointer, filesize ($FileName));
fclose($FilePointer);
// Encode and chunk split the data for the e-mail
$File=chunk_split(base64_encode($File));
// Set the receiving e-mail address
$EMail="Info@gspotracing.com";
// Set the headers of the e-mail
$Headers="From: [email]Info@gspotracing.com[/email]\n";
$Headers.="Reply-To: [email]Info@gspotracing.com[/email]\n";
$Headers.="MIME-Version: 1.0\n";
$Headers.="Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\n";
$Headers.="X-Sender: [email]Info@gspotracing.com[/email]\n";
$Headers.="X-Mailer: PHP4\n";
$Headers.="X-Priority: 3\n";
$Headers.="Return-Path: [email]Info@gspotracing.com[/email]\n";
$Headers.="This is a multi-part Contentin MIME format.\n";
// Set the Content of the e-mail
$Content="--MIME_BOUNDRY\n";
$Content.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$Content.="Content-Transfer-Encoding: quoted-printable\n";
$Content.="\n";
$Content.="".$_POST['Name']." just sent you the attached Banner that is requested to be reviewed.\n";
$Content.="\n";
$Content.="".$_POST['Email']." ---> Is the customers Email Address that will be used
for billing and statistics on the G-Spot Racing Banner Network.\n";
$Content.="\n";
$Content.="".$_POST['Time']." ---> Is the requested time period the customer has requested their
banner to be viewed on the Banner Network.\n";
$Content.="\n";
$Content.="--MIME_BOUNDRY\n";
$Content.="Content-Type: ".$_FILES['UPLDoc']['type']."; name=\"".$_FILES['UPLDoc']['name']."\"\n";
$Content.="Content-disposition: attachment\n";
$Content.="Content-Transfer-Encoding: base64\n";
$Content.="\n";
$Content.="$File\n";
$Content.="\n";
$Content.="--MIME_BOUNDRY--\n";
// Set the Subject of the e-mail
$Subject="G-Spot Banner Submittal";
// Send the e-mail
mail($EMail,$Subject,$Content,$Headers);
header("Location: /upload/success.php?oogtp=$Email");
}else
{
header("Location: /upload/error.php");
}
}
if (isset($HTTP_POST_VARS['Email'])){
mail($Email,"G-Spot Banner Submittal","
Attention: $Name,\r\n
Your Banner has successfully been submitted. Thank you for your
interest in advertising on [url]www.gspotracing.com.[/url] If there is anything
else that we can help you with, please feel free to contact us anytime.
You should receive a response on the acceptance of your submitted banner,
within 24-48 hours.\r\n
Sincerely,
G-Spot Racing Team
[url]www.gspotracing.com[/url]
Email: [email]sales@gspotracing.com[/email]\r\n
* This Email is an automated one time response to your request *",
"From: [email]support@gspotracing.com[/email]\r\n".
"Reply-To: [email]support@gspotracing.com[/email]\r\n".
"Return-Path: [email]support@gspotracing.com[/email]\r\n");
}