Jump to content

eMonk

Members
  • Posts

    223
  • Joined

  • Last visited

Everything posted by eMonk

  1. oh i see... thx for clearing that up! i use dreamweaver as my html editor & it doesn't add those forward slashes so seeing them in php examples is new to me.
  2. since i have started learning php.. i have noticed in their form fields they add a forward slash before ending their input fields, for example, <input type="text" name="name" /> is the forward slash "/" needed at the end when passing form values to php? if so, why? i believe i have excluded these in the past without any noticable problems. also.. would the forward slash be needed here? <select name="select1"> <option>PHP</option> <option>MySQL</option> </select> thanks in advance to anyone that can shed some light on this issue!
  3. i only want image uploads & the following code is loading all files *.* when you click on the browse button in my form <input type="file" name="file1" accept="image/gif, image/jpeg"> any ideas?
  4. updated code: <?php // Read POST request params into global vars $name = $_POST['name']; $to = $_POST['to']; $email = $_POST['email']; $subject = $_POST['subject']; // Obtain file upload vars $fileatt1 = $_FILES['fileatt1']['tmp_name']; $fileatt1_type = $_FILES['fileatt1']['type']; $fileatt1_name = $_FILES['fileatt1']['name']; // THIS HAS BEEN REPEATED AND I HAVE CHANGED THE FILE NAME $fileatt2 = $_FILES['fileatt2']['tmp_name']; $fileatt2_type = $_FILES['fileatt2']['type']; $fileatt2_name = $_FILES['fileatt2']['name']; $headers = "From: $email"; if (is_uploaded_file($fileatt1)) { // Read the file to be attached ('rb' = read binary) $file1 = fopen($fileatt1,'rb'); $data1 = fread($file1,filesize($fileatt1)); fclose($file1); } 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); } // 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" . "Name: " . $name . "\n\n" . "Email: " . $email . "\n\n" ; // Base64 encode the file data $data1 = chunk_split(base64_encode($data1)); $data2 = chunk_split(base64_encode($data2)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt1_type};\n" . " name=\"{$fileatt1_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt1_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data1 . "\n\n" . "--{$mime_boundary}--\n"; // THIS HAS BEEN REPEATED $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>Thank you <b>$name</b></p> <p>We have received your application and we will be in touch shortly</p>"; } else { echo "<p>Sorry, but there as an error. If the problem persists please email us at </p>"; } ?> i tried uploading 2 small gif files but only the first one is being sent, the second one isn't. i have also searched google for clues but this seems to be a big problem in php and seems no one has a solid answer to this. there are some scripts such as phpmailer that allows multiple file upload but when i tried installing it and running the test form, it sent it twice so i don't want to bother with it. its also hard to read and would like a compact version for personal use. why isn't the second file being attached to emails with the above code?
  5. thx for the reply but i still can't seem to get this to work. anymore ideas? also, is there a more compact way of obtaining file upload vars instead of copying and pasting it 10 times?
  6. i'm trying to get the following code to send multiple image attachments to my email address but it's currently only sending 1. what's wrong with this code? i can't seem to send 2 images with it... i want a total of 10 jpg/png image attachments... <?php // Read POST request params into global vars $to = 'webmaster@domain.com'; $email = $_POST['email']; $subject = $_POST['subject']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; // THIS HAS BEEN REPEATED AND I HAVE CHANGED THE FILE NAME $fileatt2 = $_FILES['fileatt2']['tmp_name2']; $fileatt_type2 = $_FILES['fileatt2']['type2']; $fileatt_name2 = $_FILES['fileatt2']['name2']; $headers = "From: $email"; 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" . "msg here" ; // 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"; // THIS HAS BEEN REPEATED $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"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p>Thank you <b>$name</b></p> <p>We have received your application and we will be in touch shortly</p>"; } else { echo "<p>Sorry, but there as an error. If the problem persists please email us at </p>"; } ?> any ideas?
  7. btw, you should probably post this in the HTML section
  8. try using align="left" in the tables like... change <table border="0" cellspacing="0" cellpadding="2" align="right"> to <table border="0" cellspacing="0" cellpadding="2" align="left">
  9. actually.. it SHOULD BE $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; and now i'm getting your echo... Failed to open file
  10. i found one typo... $DOCUMENT_ROOT = $SERVER['DOCUMENT ROOT']; should be $DOCUMENT_ROOT = $SERVER['DOCUMENT_ROOT']; (missing "_" in $SERVER['DOCUMENT ROOT']) but still getting the same error....
  11. i'm still getting the same error with @ $fp = fopen("$DOCUMENT_ROOT/orders/orders.txt", 'ab');
  12. i tried using @ $fp = fopen("http://www.domain.com/orders/orders.txt", 'ab'); & @ $fp = fopen("$DOCUMENT_ROOT/orders/orders.txt", 'ab'); but get the same error.
  13. here's my html output line 68 your if statement was also added to the php file but doesn't appear in the html output...
  14. posted in wrong section, please delete this post.
  15. i'm getting the error in the topic with this code. i don't think i'm pointing to the correct path using $DOCUMENT_ROOT. $DOCUMENT_ROOT = $SERVER['DOCUMENT ROOT']; // open file for appending @ $fp = fopen("$DOCUMENT_ROOT/www.domain.com/orders/orders.txt", 'ab'); flock($fp, LOCK_EX); if (!$fp) { echo "<p><strong>Your order could not be processed at this time. Please try again later.</strong></p></body></html>"; exit; } - the .php file is uploaded in /www.domain.com/test/processorder.php - the orders.txt is uploaded in /www.domain.com/orders/orders.txt how do i know 100% if i'm pointing to the right file in fopen?
  16. i'm getting the error in the topic with this code. i don't think i'm pointing to the correct path using $DOCUMENT_ROOT. $DOCUMENT_ROOT = $SERVER['DOCUMENT ROOT']; // open file for appending @ $fp = fopen("$DOCUMENT_ROOT/www.domain.com/orders/orders.txt", 'ab'); flock($fp, LOCK_EX); if (!$fp) { echo "<p><strong>Your order could not be processed at this time. Please try again later.</strong></p></body></html>"; exit; } - the .php file is uploaded in /www.domain.com/test/processorder.php - the orders.txt is uploaded in /www.domain.com/orders/orders.txt how do i know 100% if i'm pointing to the right file in fopen?
  17. i want to create a php form that will send my to email address once submitted. the form will include: - text fields - text area boxes - check boxes - radio buttons - list/menu drop downs - up to 10 image attachments with browse buttons & max filesize of 500kb or so any tutorials on how to do this? my book "php and mysql web development - 4th edition" doesn't cover php form processing to emails. thanks in advance!
  18. ok, thanks for the help guys! i have lots of reading to do!
  19. i understand, i would just like to read over what needs to be done to get this first project of mine to work & be a success. i'm not looking for anything too advanced... a simple user/pass login system for users to edit their personal info & later down the road to add/remove thumb pics. i would also like to fetch this info from a mysql database from their html page. any info how to do this would be lots of help.
  20. yes i will be using mysql for my database. i'm new to coding & have just purchased the book, "PHP and MySQL Web Development" to help me learn this language.
  21. i would like to create a user login system & once they log in successfully, they can edit their details such as their phone number, description, email address, etc & i would like to fetch this info on their html page. can anyone point me in the right direction?
×
×
  • 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.