Jump to content

petonii

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

petonii's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys, I got everything working in this form, i can send attachments everything is sweet, but i want to add additional information like phone numbers and names. But i can't seem to figure out where to add the code. my mate helped me with this, thats why i can't figure it out and he has gone on holidays. PLEASE HELP! i been trying for over 3 hours. Ill show both the PHP and HTML of the code <?php if ($_SERVER['REQUEST_METHOD']=="POST"){ $to="email@email.com"; $subject="email requested"; $from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">"; $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; $message=($_POST['fromdesc']); $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"; foreach($_FILES as $userfile){ $tmp_name = $userfile['tmp_name']; $type = $userfile['type']; $name = $userfile['name']; $size = $userfile['size']; if (file_exists($tmp_name)){ if(is_uploaded_file($tmp_name)){ $file = fopen($tmp_name,'rb'); $data = fread($file,filesize($tmp_name)); fclose($file); $data = chunk_split(base64_encode($data)); } $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } } $message.="--{$mime_boundary}--\n"; if (@mail($to, $subject, $message, $headers)) echo "It worked."; else echo "Failed to send"; } else { ?> And now HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1"> <table width="100%" border="0"> <tr> <td height="55"><font size="+1" face="Arial, Helvetica, sans-serif"><strong> </strong></font> <input type="text" name="fromname"> <font size="+1" face="Arial, Helvetica, sans-serif"><strong> </strong></font></td> </tr> <tr> <td height="48"><input type="text" name="fromemail"> </td> </tr> <tr> <td height="52"><input type="text" name="businessname"></td> </tr> <tr> <td height="53"><input type="text" name="website"> </td> </tr> <tr> <td height="50"><input type="text" name="address"> </td> </tr> <tr> <td height="46"><input type="text" name="phone"> </td> </tr> <tr> <td height="52"><input type="text" name="email"> </td> </tr><tr> <td height="48"><input type="file" name="file1"></td> </tr><tr> <td height="48"><input type="file" name="file2"></td> </tr><tr> <td height="48"><input type="file" name="file3"></td> </tr><tr> <td height="48"><input type="file" name="file4"></td> </tr> <tr> <td height="208"><textarea name="fromdesc" cols="40" rows="10" id="textarea2"></textarea> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Submit"> <font size="+1" face="Arial, Helvetica, sans-serif"><strong> <?php } ?> </strong></font></td> </tr> </table> </form> </body> </html> Any input would be great, i added the extra text fields in the HTML code but cant get the information to send to the email address.
  2. Ok i got a working version if anyone that doesn't know much PHP and would like a copy + paste version of send an attachment like pics from a website to an email address then here it is. save it as .php just copy and paste <html> <head> <title>E-mail with Attachment</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php if ($_SERVER['REQUEST_METHOD']=="POST"){ // we'll begin by assigning the To address and message subject $to="chassis.tk@gmail.com"; $subject="E-mail with attachment"; // get the sender's name and email address // we'll just plug them a variable to be used later $from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">"; // generate a random string to be used as the boundary marker $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; // store the file information to variables for easier access $tmp_name = $_FILES['filename']['tmp_name']; $type = $_FILES['filename']['type']; $name = $_FILES['filename']['name']; $size = $_FILES['filename']['size']; // here we'll hard code a text message // again, in reality, you'll normally get this from the form submission $message = "Here is your file: $name"; // if the upload succeded, the file will exist if (file_exists($tmp_name)){ // check to make sure that it is an uploaded file and not a system file if(is_uploaded_file($tmp_name)){ // open the file for a binary read $file = fopen($tmp_name,'rb'); // read the file content into a variable $data = fread($file,filesize($tmp_name)); // close the file fclose($file); // now we encode it and split it into acceptable length lines $data = chunk_split(base64_encode($data)); } // now we'll build the message headers $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; // next, we'll build the message body // note that we insert two dashes in front of the // MIME boundary when we use it $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"; // now we'll insert a boundary to indicate we're starting the attachment // we have to specify the content type, file name, and disposition as // an attachment, then add the file content and set another boundary to // indicate that the end of the file has been reached $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; // now we just send the message if (@mail($to, $subject, $message, $headers)) echo "Message Sent"; else echo "Failed to send"; } } else { ?> <p>Send an e-mail with an attachment:</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1"> <p>From name: <input type="text" name="fromname"></p> <p>From e-mail: <input type="text" name="fromemail"></p> <p>File: <input type="file" name="filename"></p> <p><input type="submit" name="Submit" value="Submit"></p> </form> <?php } ?> </body> </html>
  3. TY for the link. This may sound silly, but how would i attach this is my button in HTML format? I add in the button that lets you attach a file but don't know what to attach ID with. please help <?php function send_mail($MailTo = "", $SenderName = "Sender", $SenderMail = "no@reply.error", $Subject = "", $Mailcontent = "no.file", $Attachment = "no.file", $Servername = "PHPMAILSERVER", $nohtml = "[ This message should be viewed in HTML. This is a degraded version! ]"){ if(strtoupper(substr(PHP_OS,0,3)=='WIN')){ $eol="\r\n"; $sol="\n"; }elseif(strtoupper(substr(PHP_OS,0,3)=='MAC')){ $eol="\r"; }else{ $eol="\n"; } if(!isset($sol)){ $sol = $eol; } $Momentn = mktime().".".md5(rand(1000,9999)); $f_name = $Attachment; $handle = fopen($f_name, 'rb'); $f_contents = @fread($handle, filesize($f_name)); $f_contents = @base64_encode($f_contents); if($handle){ $sendfile = true; if(ini_get('mime_magic.debug')){ $Bestype = @mime_content_type($Attachment); }else{ $Bestype = 'application/octet-stream'; } if(!$Bestype){ $Bestype = 'application/octet-stream'; } $file_realname = explode("/", $Attachment); $file_realname = $file_realname[count($file_realname)-1]; $file_realname = explode("\\", $file_realname); $file_realname = $file_realname[count($file_realname)-1]; } @fclose($handle); $Mailcontentstri = explode($sol, $Mailcontent); $Mailcontentstrip = strip_tags($Mailcontentstri[0]); if(@file_exists($Mailcontentstrip)){ ob_start(); if(require($Mailcontent)){ $body = ob_get_contents(); } ob_end_clean(); }else{ if(count($Mailcontentstri) < 2){ $body = "Error loading file!"; $error = true; }else{ $body = $Mailcontent; } } $Textmsg = eregi_replace("<br(.{0,2})>", $eol, $body); $Textmsg = eregi_replace("</p>", $eol, $Textmsg); $Textmsg = strip_tags($Textmsg); $Textmsg = $nohtml.$eol.$eol.$Textmsg; $headers .= 'To: '.$MailTo.' <'.$MailTo.'>'.$eol; $headers .= 'From: '.$SenderName.' <'.$SenderMail.'>'.$eol; $headers .= "Message-ID: <".$Momentn."@".$Servername.">".$eol; $headers .= 'Date: '.date("r").$eol; $headers .= 'Sender-IP: '.$_SERVER["REMOTE_ADDR"].$eol; $headers .= 'X-Mailser: iPublications Adv.PHP Mailer 1.6'.$eol; $headers .= 'MIME-Version: 1.0'.$eol; $bndp = md5(time()).rand(1000,9999); $headers .= "Content-Type: multipart/mixed; $eol boundary=\"".$bndp."\"".$eol.$eol; $msg = "This is a multi-part message in MIME format.".$eol.$eol; $msg .= "--".$bndp.$eol; $bnd = md5(time()).rand(1000,9999); $msg .= "Content-Type: multipart/alternative; $eol boundary=\"".$bnd."\"".$eol.$eol; $msg .= "--".$bnd.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $msg .= $Textmsg.$eol; $msg .= "--".$bnd.$eol; $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8-bit".$eol.$eol; $msg .= $body.$eol; $msg .= "--".$bnd."--".$eol.$eol; if(isset($sendfile)){ $msg .= "--".$bndp.$eol; $msg .= "Content-Type: $Bestype; name=\"".$file_realname."\"".$eol; $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment;".$eol; $msg .= " filename=\"".$file_realname."\"".$eol.$eol; $f_contents = chunk_split($f_contents); $msg .= $f_contents.$eol; } $msg .= "--".$bndp."--"; if(!isset($error)){ if(@mail($MailTo, $Subject, $msg, $headers)){ return true; }else{ return false; } }else{ return false; } } ?>
  4. Hello guys n gals, Just wanted some help if possible. I have an online email form system on my website but would like people to send logos and such with there emails. I was wondering how would this be done? With my current code i want to add the user can attach up to 3 images, .jpgs and .gifs only. Please help! <?php $contact_to_email="user@gmail.com"; $contact_subject="Contact Us"; $contact_from_email="hello@gmail.com"; $contact_from_name="Woooooo"; $send_from_internal_address=false; $error_color="red"; $use_security_image=false; function previous_request_value($str) { if (isset($_REQUEST[$str]) ) return $_REQUEST[$str]; else return ''; } function cndstrips($str) { if (get_magic_quotes_gpc()) return stripslashes($str); else return $str; } $visitor_email=cndstrips(trim(previous_request_value('visitor_email'))); $visitor_name=cndstrips(trim(previous_request_value('visitor_name'))); $message_body=cndstrips(previous_request_value('message_body')); $message_subject=cndstrips(previous_request_value('message_subject')); $security_code=str_replace(' ','',cndstrips(trim(previous_request_value('security_code')))); $errors=""; $message_sent=false; function validate_email($email) { return preg_match('/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]+\.[A-Za-z0-9_\-\.]+$/', $email) == 0; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (validate_email($visitor_email) ) { $errors.="Please enter a valid email address in the form of user@place.ext<br/><br/>"; } if ($use_security_image && $security_code != $_SESSION['contact_form_security_code'] ) { $errors.="The verification code for the image presented was incorrect. Please enter a correct verification code.<br/><br/>"; } if ($message_body == '') $errors.="Please enter a message<br/><br/>"; if ($message_subject == '') $errors.="Please enter a message subject<br/><br/>"; if ($visitor_name == '') $errors.="Please enter your name<br/><br/>"; if ( !$errors ) { $ip = $_SERVER["REMOTE_ADDR"]; $httpagent = $_SERVER["HTTP_USER_AGENT"]; $time = date("D, F j, Y H:i O"); if ($visitor_name) $visitor_name_and_email="$visitor_name <$visitor_email>"; else $visitor_name_and_email="$visitor_email"; if ($contact_from_name) $contact_from_email="$contact_from_name <$contact_from_email>"; $message = " $message_body ____________________________ Browser Info: $ip $httpagent "; if ($send_from_internal_address) { $message= " From: $visitor_name_and_email Date: $time Subject: $message_subject ".$message; } if ($send_from_internal_address) { mail($contact_to_email, $contact_subject." $message_subject", $message, "From: $contact_from_email\r\nReply-To: $visitor_name_and_email"); } else { mail($contact_to_email, $contact_subject." $message_subject", $message, "From: $visitor_name_and_email"); } echo "Your message"; echo "<div style='border: 1px solid black; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;'>From: ".htmlentities($visitor_name_and_email)."<br />Re: ".htmlentities($message_subject)."<br />".htmlentities($message_body)."</div>"; echo "Has been sent. Thank you for contacting us."; $message_sent=true; } } if (!$message_sent) { $this_file = substr(strrchr($_SERVER['PHP_SELF'], "/"), 1); ?>
  5. Hello fellow programmers, I am new to this site and was looking around for some good advice or if i am lucky some help. I am starting off a basic local business search project just for some practice. I need some tutorial or some example code. I don't want to waste too much time for others so ill make this quick. http://au.local.yahoo.com/ This link shows 2 search bars. I only want to know the postcode search side of things. I wanna be able to write 90210 for example and then every business with the postcode 90210 comes up on a custom page. How do you label each business with a postcode and make it up on a section of my website? I hope this is clear. If any fingers can be pointed to a very clear source that would be great. I understand some coding but not advanced enough to write it from scratch. Thanks in advanced Peace >.<
×
×
  • 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.