Jump to content

shahzad

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by shahzad

  1. i am trying sample code to send form to an email with two attachment i am receiving 1st attachment but i am now able to receive second attachment. http://www.royalcustoms.net/phpemail/ my code is below for mail.php <html> <head> <title> Sending Email </title> </head> <body> <?php // Read POST request params into global vars $to = $_POST['to']; $from = $_POST['from']; $subject = $_POST['subject']; $message = $_POST['message']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; // Obtain file upload vars $fileatt2 = $_FILES['fileatt2']['tmp_name']; $fileatt2_type = $_FILES['fileatt2']['type']; $fileatt2_name = $_FILES['fileatt2']['name']; $headers = "From: $from"; if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // 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"; } if (is_uploaded_file($fileatt2)) { // Read the file to be attached ('rb' = read binary) $file2 = fopen($fileatt2,'rb'); $data2 = fread($file2,filesize($fileatt2)); fclose($file2); // Base64 encode the file data $data2 = chunk_split(base64_encode($data2)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt2_type};\n" . " name=\"{$fileatt2_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt2_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data2 . "\n\n" . "--{$mime_boundary}--\n"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p>Mail sent! Yay PHP!</p>"; } else { echo "<p>Mail could not be sent. Sorry!</p>"; } ?> </body> </html>
  2. excellent idea litebearer... how to grab name of file in folder... can you please help me with function name or what it called so that i can learn to use it.. thanks again
  3. i have around 200 images in a folder i want to upload it to the server and i want to store there name in mysql database. i know the script to upload 1 at a time but i need to select the file every time is it possible to give directory path and script will get all the images and get there name insert to the database?? thanks for your time and help in advance
  4. Thaks pbs it works jl5501 i tried offset but i am getting an error. i think offset is not valid without limit... thankyou guys
  5. ok thanks 1 more thing now as it is news table i dont know how many record it will have at that point of time but everytime i will display news in front end i need to skip 5 record and display all.. so there is a way where i can tell skip first 5 and get all records?? thanks again
  6. i have a table name "News" I want to fetch records from 6 onwards what will be the query for it. for example if table news have 10 records what i want is to fetch record 6 to 10 or we can say skip first 5 records. Thanks in advance Regards, Shahzad
  7. thanks yes to use date is efficient only 2 line code and im done...
  8. thanks both of you... its working fine jl5501 yes provide me the code i want to see how to use strftime and have st, nd, rd, th bit.. Thanks Again
  9. I am storing date as 2010-01-26 in Mysql But i want to display it as November 29th, 2009 to the user how to format the date?? thanks in advance
  10. hahaha yes yes i got an idea thanks your help.
  11. the query for scrolling is following but i am just scrolling date with short news. $querynews="select * from tablenews"; ok i got an idea now how to control news to diplay current month news.. but what about archive now clients wants when he will click News Archive a list of months and years appears which have news appear so that users can click and view all the news for that following month..
  12. You will need to be more specific. Post your current code and explain which available columns exist in your database. For example, is there a "date" column in your database that you can use to sort the news by date? Are you currently even using a database and PHP? my website address is http://www.omegadubai.com/ on left side you can see news scrolling panel. link to news detail page http://www.omegadubai.com/News_Detail.php?Pageid=5 yes i am using MySql as database Tablename : tablenews fields TableID Date NewsScroll NewsTitle NewsDescription Image Link PDF thanks for your time bro
  13. in my website there is news scrolling panel where what ever the new inserted in database scrolls. but what i need now that only fresh or current month news will scroll and old news will archived where i can display it in archive page in monthly or yearly view. is it possible if yes what will be the logic or working behind it. Thanks in advance Thanks & Best regards, Shahzad Ahmed
  14. I am working on one small CMS for a website. where admin can enter any content. in my system localhost it was working fine. but when i have uploaded to client server query is not processing. then i got to know some where in content he was typing ( Dubai's ) may be this is the problem. but when i try same content locally it work. is it some thing to do with PHO setting?? or these is any soloution for sql injection?
  15. Thanks Thanks its working fine one more thing if i want to show full text once user clicks ... is it possible or not?
  16. thanks for you help.. but bye this substr($string,0,300) i get first 300 chars but now how to add 3 dots if there is more data.. if data is less then 300 then no need for dots.
  17. $query_data['Comments']; i have one comments filed but what i want now is. if data is more than 1-2 lines or more than 100 characters end user with see only 2 lines and ... at the end so that he can click read more to view all. please help me with it. Thanks in advance
  18. i tried this way but it didnt work $input = $query_data['PageContent']; $ouput = preg_replace(array('#<p>#', '#</p>#'), '', $input, 1); echo $output; so i tried like this its working fine. but is it the good to do? $outout = str_replace("</p>","<br />",str_replace("<p>", "", "$query_data[PageContent]")); echo $output;
  19. but in my case sample data is like <p> some data </p> <p> some data </p><br> <p> some data </p> so i want <p> tag and <br> tag later in data but i dont want first <p> </p> tag..
  20. i am using tiny_mce as a text editor for my CMS. buy now the problem is it add <p> tag with data so while retrieving the data for front end i get an extra space. so there is any why that i can remove <p> </p> from first paragraph. i tried using strip_tags()... but it strip all the others tag like <br> etc etc..
×
×
  • 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.