Jump to content

Ne0_Dev

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Ne0_Dev's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi All, thanks for the suggestions. I have decided to keep it simple and take requinix advice and created a new table called categories and store the primary key in the video table. I have just one other question regarding the structure of a SQL query for this database. Would someone be able to give me an example of how to list all videos and output the correct theme or category next to it? I assume I will need to use a JOIN of some sort. Not sure if this is any help but I am setting the categoryid and themeid field in the video table to 0 depending on which of these 2 the video has been associated to. E.G If video is associated to a theme then the categoryid in the video table will set to 0 and vice versa.
  2. Hi All, I am after a bit of advice/suggestions on the following scenario: I have a site that has 3 tables in it's database: Videos Themes Customers At present both primary keys of the themes table and customers table are stored in the videos table as foreign keys. Each video can only be associated to 1 customer and 1 theme. My question is what would be the best way to introduce some separate categories to which a video can be associated to that is not classed as a theme. E.G. each video can only be associated to a single theme or category but not both. Would I need to add another table or can I use the existing ones and add an additional field to them? Any help gratefully received.
  3. Hi Gizmola, Thanks for your help with this I have taken your advice and managed to implement a successful solution that works just as I hoped! Cheers Ne0_Dev
  4. gizmola, thanks for the link and I have had a go at implementing it: <?php $sql = "SELECT c.name, v.* FROM video v INNER JOIN category c ON c.cat_id = v.cat_id WHERE v.client_id = $customerid ORDER BY c.cat_id, video_id DESC"; $result = mysql_query($sql) or die (mysql_error()); $category_id = ''; while($categoryrow = mysql_fetch_assoc($result)) { if($categoryrow['cat_id'] != $category_id) { ?> <div class="themeheader"><h5><?php echo $categoryrow['name']; ?></h5></div> <?php $category_id = $categoryrow['cat_id']; } ?> <Br /> <div class="videos"> <ul> <li id="categoryList"><a href="film-details.php?video_id=<?php echo $categoryrow['video_id']; ?>"><img src="+_1m4g35/<?php echo $categoryrow['thumbnail']; ?>" alt="<?php echo $categoryrow['title']; ?>" title="<?php echo $categoryrow['title']; ?>" width="291" height="142" border="0" /></a> <h2><?php echo $categoryrow['title']; ?></h2> <p><?php $limit = 100; if (strlen($categoryrow['description']) > $limit) $description = substr($categoryrow['description'], 0, strrpos(substr($categoryrow['description'], 0, $limit), ' ')) . '... <a href="film-details.php?video_id='.$categoryrow['video_id'].'">read more</a>'; echo $description; ?> </p> </ul> <br class="clearfloat" /> </div> <?php } //end category loop ?> </div> The only problem I have now is that each video is not being output under a new <li> element under the same category.
  5. Sorry forgot to mention in my previous post that this is limiting the results by customer id and is returning only categories that have videos associated to them. The only thing I cannot seem to do is get videos that are in the same category appearing under one category header. At the moment I have 2 videos under the same category but category header appears twice, once with one video and once with the other video. Thanks in advance..
  6. Hi gizmola, I have had a go at implementing your suggestions and this si what i have come up with: <?php $sql = "SELECT c.name, v.* FROM video v INNER JOIN category c ON c.cat_id = v.cat_id WHERE v.client_id = $customerid ORDER BY c.cat_id, video_id DESC"; $result = mysql_query($sql) or die (mysql_error()); while($categoryrow = mysql_fetch_assoc($result)) { ?> </p> <div class="themeheader"><h5><?php echo $categoryrow['name']; ?></h5></div> <Br /> <div class="videos"> <ul> <li id="categoryList"><a href="film-details.php?video_id=<?php echo $categoryrow['video_id']; ?>"><img src="+_1m4g35/<?php echo $categoryrow['thumbnail']; ?>" alt="<?php echo $categoryrow['title']; ?>" title="<?php echo $categoryrow['title']; ?>" width="291" height="142" border="0" /></a> <h2><?php echo $categoryrow['title']; ?></h2> <p><?php $limit = 100; if (strlen($categoryrow['description']) > $limit) $description = substr($categoryrow['description'], 0, strrpos(substr($categoryrow['description'], 0, $limit), ' ')) . '... <a href="film-details.php?video_id='.$categoryrow['video_id'].'">read more</a>'; echo $description; ?> </p> </ul> <br class="clearfloat" /> </div> <?php } //end category loop ?> </div> This is limiting the results by customer id and is returning only categories that have videos associated to them. the only thing I cannot seem to do is get videos that are in the same category appearing under one category header. At the moment I have 2 videos under the same category but category header appears twice, once with one video and once with the other video. Thanks in advance..
  7. Hi spiderwell/gizmola, Thank you both for your prompt comments/suggestions. I did understand why all the categories were being returned, but couldn't figure out the right way to limit them. I am not too familiar with JOINS and the which way round the tables go. Would either of you be able to provide an example for me? I have had a go with this? $sql = "SELECT * FROM video INNER JOIN category ON category.cat_id = video.cat_id ORDER BY category_id, video_id DESC";
  8. Hi All, Wondered if someone could help me out with a sql query that I am having difficulty with? My database consists of 3 tables, clients, video, category. The video table stores the primary key value of the clients table and the category table as a foreign key. What I am trying to achieve is return all the videos that are associated to a particular client and group them under the relevant category. If there are now videos that match the category then I do not want to display the category. Here is my code so far: <?php $sql = "SELECT category.cat_id, category.name AS catname FROM category"; $result = mysql_query($sql) or die (mysql_error()); while($categoryrow = mysql_fetch_assoc($result)) { ?> </p> <div class="themeheader"><h5><?php echo $categoryrow['catname']; ?></h5></div> <Br /> <?php $vsql = "SELECT video.video_id, video.title, video.description, video.thumbnail FROM video WHERE video.cat_id = '" . $categoryrow['cat_id'] . "' AND video.client_id = $customerid ORDER BY video.video_id DESC"; $vresult = mysql_query($vsql) or die (mysql_error()); ?> <div class="videos"> <ul> <?php while($videorow = mysql_fetch_assoc($vresult)) { ?> <li id="categoryList"><a href="film-details.php?video_id=<?php echo $videorow['video_id']; ?>"><img src="+_1m4g35/<?php echo $videorow['thumbnail']; ?>" alt="<?php echo $videorow['title']; ?>" title="<?php echo $videorow['title']; ?>" width="291" height="142" border="0" /></a> <h2><?php echo $videorow['title']; ?></h2> <p><?php $limit = 100; if (strlen($videorow['description']) > $limit) $description = substr($videorow['description'], 0, strrpos(substr($videorow['description'], 0, $limit), ' ')) . '... <a href="film-details.php?video_id='.$videorow['video_id'].'">read more</a>'; echo $description; ?> </p> <?php } //end video loop?> </ul> <br class="clearfloat" /> </div> <?php } //end category loop ?> </div> The above code is the closest I have got but it still outputs the categories even when there are no videos that match the category id and the client id. Any help in the right direction gratefully received as I am gradually going insane! :-\
  9. Hi Guys, I'm after a bit of help/guidance on an issue I am currently trying to resolve. I currently have a page where I use setlocale(LC_MONETARY) to automatically format values to a specific currency depending on which country parameter I pass to this function. At the moment I only require one currency for all values on the page. I am now trying to figure out a way to have different currency values on the same page and just wondered if it is possible to specify multiple setlocale on a page? If so I would need to use either an if/else/if statement or a switch statement to determine which one to use based on the country value of the record being returned from the database. At the moment I am specifying the setlocale in a php block at the top of the page. Any thoughts or suggestions are most appreciated. Ne_Dev
  10. Hi All, I guess my request was a bit vague due to the lack of responses to my original post. Therefore I am hoping that by explaining my scenario a bit better someone might be able to point my in the right dirrection. I have an update page that has 6 images each with a check box to determine whether it is to be replaced during the update process. The problem I am having is that when the form is submitted and only a couple of the images are selected to be replaced, I am not able to keep track of the correct filename to insert into the table. I think it has something to do with this part of the code but I am not 100% sure. I am using the values stored in the $uploaded array to store in the database: //initialize new images to be uploaded $files = array(); foreach ($_FILES['image'] as $k => $l) { foreach ($l as $i => $v) { if (!array_key_exists($i, $files)) $files[$i] = array(); $files[$i][$k] = $v; } } // create an array here to hold file names $uploaded = array(); foreach ($files as $file) { $handle = new Upload($file); if ($handle->uploaded) { // create a little array for this set of pictures $this_upload = array(); $handle->file_safe_name = true; $handle->file_auto_rename = true; $handle->file_max_size = '512000'; $handle->allowed = array('image/jpeg', 'image/jpg'); $handle->Process($dir_dest); if ($handle->processed) { echo $handle->file_dst_name; // store the image filename $this_upload['image'] = $handle->file_dst_name; } else { echo 'error : ' . $handle->error; } // add this set of pictures to the main array $uploaded[] = $this_upload; } If someone could possibly give me some idea as to how to achieve this it would be most appreciated. Ne0_Dev
  11. Hi, I have successfully implemented this class http://www.verot.net/home.htm to upload 6 images as per the examples given in the FAQ on this site and also storing the correct filename in my database table. My question relates to an update record page that I have, that allows for the changing of images associated with a record. As each image name is stored in a separate field in the table I am having difficulty updating the correct field with the correct image name. This I believe is down to the fact that not all images are being replaced and therefore the $_FILES array has empty records depending on which images were selected to be changed. I am using the values stored in the $uploaded array to store in the database. Having carried out some testing on the contents of the arrays during this process, I am still none the wiser so I am hoping that someone maybe able to point me in the right direction. Here is the code that I am using: //initialize new images to be uploaded $files = array(); foreach ($_FILES['image'] as $k => $l) { foreach ($l as $i => $v) { if (!array_key_exists($i, $files)) $files[$i] = array(); $files[$i][$k] = $v; } } // create an array here to hold file names $uploaded = array(); foreach ($files as $file) { $handle = new Upload($file); if ($handle->uploaded) { // create a little array for this set of pictures $this_upload = array(); $handle->file_safe_name = true; $handle->file_auto_rename = true; $handle->file_max_size = '512000'; $handle->allowed = array('image/jpeg', 'image/jpg'); $handle->Process($dir_dest); if ($handle->processed) { echo $handle->file_dst_name; // store the image filename $this_upload['image'] = $handle->file_dst_name; } else { echo 'error : ' . $handle->error; } // add this set of pictures to the main array $uploaded[] = $this_upload; } } Any help greatfully received. Ne0_Dev
  12. Hi I am trying to use this code to upload 4 images format the filename and the insert the new filename into the correct field in the table. the upload and insert works fine however i am unable to assign the correct formatted filename to each of the image variables to get inserted into the table. any help would be greatly appreciated. <?php // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 512000); // check if form has been submitted if (array_key_exists('submit', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', '/uploadedimages/'); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/jpeg', 'image/jpg'); foreach ($_FILES['image']['name'] as $number => $file) { // replace any spaces in the filename with underscores $file = str_replace(' ', '_', $file); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'][$number] > 0 || $_FILES['image']['size'][$number] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type'][$number]) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error'][$number]) { case 0: // check if a file of the same name has been uploaded if (!file_exists(UPLOAD_DIR.$file)) { // move the file to the upload folder and rename it $success = move_uploaded_file($_FILES['image']['tmp_name'][$number], UPLOAD_DIR.$file); } else { // get the date and time ini_set('date.timezone', 'Europe/London'); $now = date('Y-m-d-His'); $success = move_uploaded_file($_FILES['image']['tmp_name'][$number], UPLOAD_DIR.$now.$file); } if ($success) { $result[] = "$file uploaded successfully"; } else { $result[] = "Error uploading $file. Please try again."; } break; case 3: $result[] = "Error uploading $file. Please try again."; default: $result[] = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'][$number] == 4) { $result[] = 'No file selected'; } else { $result[] = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: jpeg"; } } // get form field values and assign to variable $listingtype = $_POST['listingtype']; $proptype = $_POST['proptype']; $housenum = $_POST['housenum']; $addr1 = $_POST['addr1']; $addr2 = $_POST['addr2']; $country = $_POST['country']; $state = $_POST['state']; $city = $_POST['city']; $pcode = $_POST['pcode']; $price = $_POST['price']; $bedrooms = $_POST['bedrooms']; $bathrooms = $_POST['bathrooms']; $parking = $_POST['parking']; $garden = $_POST['garden']; $shortdes = $_POST['shortdes']; $longdes = $_POST['longdes']; $feature1 = $_POST['feature1']; $feature2 = $_POST['feature2']; $feature3 = $_POST['feature3']; $feature4 = $_POST['feature4']; $feature5 = $_POST['feature5']; $feature6 = $_POST['feature6']; $image1 = $_FILES['image'][$number][0]; $image2 = $_FILES['image'][$number][1]; $image3 = $_FILES['image'][$number][2]; $image4 = $_FILES['image'][$number][3]; $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die ('Cannot connect to MySQL server'); mysql_select_db($dbdatabase, $db) or die ('Cannot open database'); $sql = "INSERT INTO nxtbl_property (listingType, propertyType, housenum, addr1, addr2, country, state, city, pcode, price, bedrooms, bathrooms, parking, garden, shortdes, longdes, feature1, feature2, feature3, feature4, feature5, feature6, image1, image2, image3, image4) VALUES('$listingtype', '$proptype', '$housenum', '$addr1', '$addr2', '$country', '$state', '$city', '$pcode', '$price', '$bedrooms', '$bathrooms', '$parking', '$garden', '$shortdes', '$longdes', '$feature1', '$feature2', '$feature3', '$feature4', '$feature5', '$feature6', '$image1', '$image2', '$image3', '$image4')"; mysql_query($sql) or die(mysql_error()); header("Location: " .$config_basedir . "createsuccess.php"); } ?>
  13. Hi, I have managed to get the form to process ok, however I think I may have got the validation mixed up. At present the form submits ok if all required fields are completed. As the file attachment is not a required field this works as intended. However if a file is attached that is either too large or not of the permitted file types the form still sends the rest of the information minus the file. The correct error message is being output to the form, but the mail processing script is not being halted if there is a problem with file being attached. I think it must be pretty simple but it's driving me mad! Any suggestions/help will be greatly appreciated. Here is my code: <?php ini_set('display_errors', 1); error_reporting(E_ALL); // define a constant for the maximum file size define ('MAX_FILE_SIZE', 1048576); //mail processing script if (array_key_exists('send', $_POST)) { // remove escape characters from POST array if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } $to = '[email protected]'; if (!empty($_POST['address'])) { $subject = 'SUSPECTED SPAM'; } else { $subject = 'Project Brief Form'; } // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'application/pdf', 'application/vnd.ms-powerpoint'); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['fileatt']['size'] > 0 && $_FILES['fileatt']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; } else { $error = 'The attachment exceeds the maximum file size of 1mb.'; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['fileatt']['type']) { $typeOK = true; break; } } if (!$typeOK) { $error = 'The file is not one of the permitted types (see below).'; } if ($_FILES['fileatt']['error'] == 4) { $error = ''; } // list expected fields $expected = array('name', 'company', 'email', 'phone', 'projecttitle', 'projectdetails', 'fileatt'); // set required fields $required = array('name', 'email', 'phone', 'projecttitle', 'projectdetails'); // create empty array for any missing fields $missing = array(); // assume that there is nothing suspect $suspect = false; // create a pattern to locate suspect phrases $pattern = '/Content-Type:|Bcc:|Cc:/i'; // function to check for suspect phrases function isSuspect($val, $pattern, &$suspect) { // if the variable is an array, loop through each element // and pass it recursively back to the same function if (is_array($val)) { foreach ($val as $item) { isSuspect($item, $pattern, $suspect); } } else { // if one of the suspect phrases is found, set Boolean to true if (preg_match($pattern, $val)) { $suspect = true; } } } // check the $_POST array and any subarrays for suspect content isSuspect($_POST, $pattern, $suspect); if ($suspect) { $mailSent = false; unset($missing); } else { // process the $_POST variables foreach ($_POST as $key => $value) { // assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); // if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } // otherwise, assign to a variable of the same name as $key elseif (in_array($key, $expected)) { ${$key} = $temp; } } } // validate the email address if (!empty($email)) { // regex to identify illegal characters in email address $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; // reject the email address if it deosn't match if (!preg_match($checkEmail, $email)) { $suspect = true; $mailSent = false; unset($missing); } } // go ahead only if not suspsect and all required fields OK if (!$suspect && empty($missing)) { // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // build the message $htmlmsg = "<html>\n"; $htmlmsg .= "<body style=\"font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#666666;\">\n"; $htmlmsg .= "<b>Name:</b> $name<br><br>\n"; $htmlmsg .= "<b>Company Name:</b> $company<br><br>\n"; $htmlmsg .= "<b>Email:</b> $email<br><br>\n"; $htmlmsg .= "<b>Telephone Number:</b> $phone<br><br>\n"; $htmlmsg .= "<b>Project Title:</b> $projecttitle<br><br>\n"; $htmlmsg .= "<b>Project Details:</b> $projectdetails<br><br>\n"; $htmlmsg .= "</body>\n"; $htmlmsg .= "</html>\n"; // Add a multipart boundary above the html message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $htmlmsg . "\n\n"; //check if file has been uploaded and is of allowed MIME type and size if (is_uploaded_file($fileatt) && $typeOK && $sizeOK) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } // create additional headers $headers = "From: www.foo.co.uk<[email protected]>"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; if (!empty($email)) { $headers .= "\nReply-To: $email"; } // send it $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset($missing); } } } ?>
  14. This is the error message I get when browsing to the page. Parse error: syntax error, unexpected $end in Thanks in advance
  15. Hi all, Just wondered if someone could take a look at my code below and point out where I am going wrong. This form should send the information and an attached file to the recipient using the Swift Mailer class, however I am having a few issues with the validation. I am still getting to grips with php so apologize if this is a relativel simple fix. <?php // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 1048576); //mail processing script if (array_key_exists('send', $_POST)) { // remove escape characters from POST array if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('application/msword', 'application/pdf', 'application/vnd.ms-powerpoint'); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'] > 0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type']) { $typeOK = true; break; } } //set sender information for SMTP authentication $senderEmail = "[email protected]"; $senderName = "Website"; //check for suspected SPAM Bots if (!empty($_POST['address'])) { $subject = 'SUSPECTED SPAM'; } else { $subject = 'Form'; } // list expected fields $expected = array('name', 'company', 'email', 'phone', 'projecttype', 'enquiry', 'bestcontact', 'besttime', 'file'); // set required fields $required = array('name', 'email', 'phone', 'enquiry'); // create empty array for any missing fields $missing = array(); // assume that there is nothing suspect $suspect = false; // create a pattern to locate suspect phrases $pattern = '/Content-Type:|Bcc:|Cc:/i'; // function to check for suspect phrases function isSuspect($val, $pattern, &$suspect) { // if the variable is an array, loop through each element // and pass it recursively back to the same function if (is_array($val)) { foreach ($val as $item) { isSuspect($item, $pattern, $suspect); } } else { // if one of the suspect phrases is found, set Boolean to true if (preg_match($pattern, $val)) { $suspect = true; } } } // check the $_POST array and any subarrays for suspect content isSuspect($_POST, $pattern, $suspect); if ($suspect) { $mailSent = false; unset($missing); } else { // process the $_POST variables foreach ($_POST as $key => $value) { // assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); // if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } // otherwise, assign to a variable of the same name as $key elseif (in_array($key, $expected)) { ${$key} = $temp; } } } // validate the email address if (!empty($email)) { // regex to identify illegal characters in email address $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; // reject the email address if it deosn't match if (!preg_match($checkEmail, $email)) { $suspect = true; $mailSent = false; unset($missing); } } $file_path = $_FILES["attachment"]["tmp_name"]; $file_name = $_FILES["attachment"]["name"]; $file_type = $_FILES["attachment"]["type"]; // go ahead only if not suspsect and all required fields OK if (!$suspect && empty($missing)) { //Everything looks ok, we can start Swift require_once "../../../../swiftMailer/Swift.php"; require_once "../../../../swiftMailer/Swift/Connection/SMTP.php"; //Enable disk caching if we can if (is_writable("/tmp")) { Swift_CacheFactory::setClassName("Swift_Cache_Disk"); Swift_Cache_Disk::setSavePath("/tmp"); } //Create a Swift instance $swift =& new Swift(new Swift_Connection_SMTP("smptaddress")); //Create the sender from the details we've been given $sender =& new Swift_Address($senderEmail, $senderName); // build the message $body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:14px; color:#666666;\">\n"; $body .= "<b>Name:</b> $name<br><br>\n"; $body .= "<b>Company Name:</b> $company<br><br>\n"; $body .= "<b>Email:</b> $email<br><br>\n"; $body .= "<b>Telephone Number:</b> $phone<br><br>\n"; $body .= "<b>Project Type:</b> $projecttype<br><br>\n"; $body .= "<b>Enquiry Details:</b> $enquiry<br><br>\n"; $body .= "<b>Best contact method:</b> $bestcontact<br><br>\n"; $body .= "<b>Best time to contact:</b> $besttime<br><br>\n"; $body .= "</body>\n"; //Create the message to send $message =& new Swift_Message($subject); $message->setContentType("text/html"); $message->attach(new Swift_Message_Part($body)); //If an attachment was sent, attach it if ($file_path && $file_name && $file_type && sizeOK && typeOK) { $message->attach( new Swift_Message_Attachment(new Swift_File($file_path), $file_name, $file_type)); } //Try sending the email $sent = $swift->send($message, "[email protected]", $sender); //Disconnect from SMTP, we're done $swift->disconnect(); if ($sent) { unset($missing); } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.