Jump to content

Irresistable

Members
  • Posts

    173
  • Joined

  • Last visited

    Never

Everything posted by Irresistable

  1. I'm not bumping, I'm just posting updates to how far I've got. I actually have something now. What i've got, is a full script, I have a maximum of 6 fields. The javascript for the form is shown in the first post. When I send a mail, it sends perfectly fine. Though it doesn't get an attachment at all. This is what i've got. echo'<center>'; if(isset($_POST['submit'])){ $forename = $_POST['forename']; $surname = $_POST['surname']; $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$"; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $user_code = $_POST['captcha']; if(!$forename || !$surname || $forename == 'forenames' || $surname == 'surname'){ $error['name'] = '- <span style="color:red;">Required!</span>'; } if(!$email || !eregi($regex,($email))){ $error['email'] = '- <span style="color:red;">Required!</span>'; } if(!$subject || strlen($subject = trim($subject)) == 0){ $error['subject'] = '- <span style="color:red;">Required!</span>'; } if(!$message || strlen($message = trim($message)) == 0){ $error['message'] = '- <span style="color:red;">Required!</span>'; } elseif(strlen($message) < 10){ $error['message'] = '- <span style="color:red;">Below 10 characters!</span>'; } if (!$user_code){ $error['captcha'] = '- <span style="color:red;">Required!</span>'; } elseif ($user_code != $_SESSION['ckey']){ $error['captcha'] = '- <span style="color:red;">Incorrect try again!</span>'; } if(!isset($error)){ $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $to = "admin@developers-community.com"; $name = "$forename $surname - Guest"; $from = stripslashes($name)."<".stripslashes($email).">"; $header = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; $body = "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 $name\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)); } $body .= "--{$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"; } } $body .="--{$mime_boundary}--\n"; mail($to, $subject, $body, $header); $to = $email; $name = "$forename $surname"; $email = "no-reply@developers-community.com"; $body = "Dear $name,\nThank you for your mail to us. Please wait patiently while we review it and get back to you. \nMeanwhile, You can use any of the other features within http://www.developers-community.com \n\n Your's Truly\nAdmin\nDeveloper's Community\n\nIn any case, do not reply to this email!"; $header = "from: Developers Community - Admin <$email>"; mail($to, $subject, $body, $header); echo '<span style="color:red";>Your mail has been sent.<br /> You will recieve a reply within up to 48 hours. This may take longer on busy days.<br /> You should have recieved an email stating we have recieved your mail, this may be in your Junk Folder.</span>'; } } echo "<table width=\"36%\" border=\"0\"> <form action=\"\" method=\"post\" onSubmit=\"rememberinput('forename', 'surname', 'email', 'subject', 'message')\"> <tr> <td> <div id=\"files_list\"></div> <div style=\"margin-right:250px;\"><span style=\"color: #F00\">*</span>Your Full Name ".$error['name']."<br /> <input type=\"text\" name=\"forename\" id=\"name\" value=\"forename\" onfocus=\"if(this.value=='forename'){this.value='';}\" onblur=\"if(this.value==''){this.value='forename';}\" class=\"textboxsup\" size=\"22\"/> <input type=\"text\" name=\"surname\" id=\"surname\" value=\"surname\" onfocus=\"if(this.value=='surname'){this.value='';}\" onblur=\"if(this.value==''){this.value='surname';}\" class=\"textboxsup\" size=\"22\"/><br /> <span style=\"color: #F00\">*</span>Your Email Address ".$error['email']."<br /> <input name=\"email\" type=\"text\" id=\"email\" value=\"".$_POST['email']."\" size=\"50\" class=\"textboxsup\"/><br /> <span style=\"color: #F00\">*</span>Subject ".$error['subject']."<br /> <input name=\"subject\" type=\"text\" id=\"subject\" value=\"".$_POST['subject']."\" size=\"50\" class=\"textboxsup\"/><br /> Add An Attachment (optional)<br /> <input id=\"my_file_element\" type=\"file\" name=\"file_1\" size=\"45\" class=\"textboxsup\"></div> <script> var multi_selector = new MultiSelector(document.getElementById('files_list'), 6); multi_selector.addElement(document.getElementById('my_file_element')); </script> </td></tr> <tr><td><span style=\"color: #F00\">*</span>Message ".$error['message']."</td></tr> <tr> <td><textarea name=\"message\" cols=\"90\" rows=\"12\" class=\"textboxsup\" id=\"message\" value=\"".$_POST['message']."\"></textarea></td> </tr> <tr> <td><span style=\"color: #F00\">*</span>Verfication<span style=\"width:149px;\"> (Are you human?) ".$error['captcha']."</span></td> </tr> <tr> <td> <div style=\"width:160px; float:right; margin-right:265px; margin-top:6px;\"><span style=\"width:149px;\">The answer is: <input name=\"captcha\" class=\"textboxsup\" id=\"captcha\" size=\"5\" maxlength=\"2\" /> </span></div> <div style=\"width:149px; margin-right:300px;\"> <span style=\"text-align: center\"> <img src=\"inc/pngimg.php\" alt=\"\" width=\"148\" height=\"30\" style=\"border:1px solid #448DC4;\" name=\"captcha\"/> </span> <span style=\"text-align: center\"> <a href=\"#\" onclick=\"Start();\">Refresh</a> <strong>/</strong> <a href=\"#\" onmouseover=\"document.getElementById('tip').style.display='';\" onmouseout=\"document.getElementById('tip').style.display='none';\">Whats this?</a></span><br /> </div> <span id=\"tip\" style=\"margin-left:120px; margin-top:3px; display:none\"> A captcha is to check if you are human or not. It's required that you fill it in! </span></td> </tr> <tr> <td><input name=\"submit\" type=\"submit\" value=\"submit\"/></td> </tr> </form> </table>"; echo'<center>'; } ?> Someone please help me
  2. I found this: $files = array("file_1.ext","file_2.ext","file_3.ext",......); On http://www.emanueleferonato.com/2008/07/22/sending-email-with-multiple-attachments-with-php/ What it'd be.. is getting $files from the File inputs id's (6 id's in total) I'm not sure on the ID's of them.. or what to do.
  3. http://www.geekology.co.za/blog/2009/06/sending-emails-with-attachments-using-php-mail-function/ I looked at this, but this is sending attachments with: $attachment = chunk_split(base64_encode(file_get_contents("geekology.zip"))); Though I'm not sure what that'd be for my php, as it uses multiple attachments, with multiple file fields, along with the ID's of each one.
  4. I have a contact form with multiple attachings using a single input type file. (It uses multiples, but they disappear and a new one gets made) A test of it can be seen here http://www.developers-community.com/support.php Just use the browse option. I'm wondering how to send it with attachments coming up shown in the email when recieved on the other end. This is my form. (Echo'd) echo "<table width=\"36%\" border=\"0\"> <form action=\"\" method=\"post\" onSubmit=\"rememberinput('forename', 'surname', 'email', 'subject', 'message')\"> <tr> <td> <div id=\"files_list\"></div> <div style=\"margin-right:250px;\"><span style=\"color: #F00\">*</span>Your Full Name ".$error['name']."<br /> <input type=\"text\" name=\"forename\" id=\"name\" value=\"forename\" onfocus=\"if(this.value=='forename'){this.value='';}\" onblur=\"if(this.value==''){this.value='forename';}\" class=\"textboxsup\" size=\"22\"/> <input type=\"text\" name=\"surname\" id=\"surname\" value=\"surname\" onfocus=\"if(this.value=='surname'){this.value='';}\" onblur=\"if(this.value==''){this.value='surname';}\" class=\"textboxsup\" size=\"22\"/><br /> <span style=\"color: #F00\">*</span>Your Email Address ".$error['email']."<br /> <input name=\"email\" type=\"text\" id=\"email\" value=\"".$_POST['email']."\" size=\"50\" class=\"textboxsup\"/><br /> <span style=\"color: #F00\">*</span>Subject ".$error['subject']."<br /> <input name=\"subject\" type=\"text\" id=\"subject\" value=\"".$_POST['subject']."\" size=\"50\" class=\"textboxsup\"/><br /> Add An Attachment (optional)<br /> <input id=\"my_file_element\" type=\"file\" name=\"file_1\" size=\"45\" class=\"textboxsup\"></div> <script> var multi_selector = new MultiSelector(document.getElementById('files_list'), 6); multi_selector.addElement(document.getElementById('my_file_element')); </script> </td></tr> I have the file element, with a div which is floated right which displays the files. Here is the javascript function behind it. function MultiSelector( list_target, max ){ this.list_target = list_target; this.count = 0; this.id = 0; if( max ){ this.max = max; } else { this.max = -1; }; this.addElement = function( element ){ if( element.tagName == 'INPUT' && element.type == 'file' ){ element.name = 'file_' + this.id++; element.multi_selector = this; element.onchange = function(){ var new_element = document.createElement( 'input' ); new_element.type = 'file'; new_element.size = '45'; new_element.setAttribute('style', 'font:100% Verdana, Arial, Helvetica, sans-serif;'); this.parentNode.insertBefore( new_element, this ); this.multi_selector.addElement( new_element ); this.multi_selector.addListRow(this); this.style.position = 'absolute'; this.style.display = 'none'; }; if( this.max != -1 && this.count >= this.max ){ element.disabled = true; }; this.count++; this.current_element = element; } else { alert( 'Error: not a file input element' ); }; }; this.addListRow = function( element ){ var new_row = document.createElement( 'div' ); new_row.element = element; new_row.setAttribute('style', 'padding:2px 10px 3px 10px; margin-bottom:1px; background:#ffc; font:100% Verdana, Arial, Helvetica, sans-serif;'); var deletelink = document.createElement('a'); var t = document.createTextNode("X"); deletelink.setAttribute('href', '#'); deletelink.setAttribute('style', 'float:right;'); deletelink.onclick= function(){ this.parentNode.element.parentNode.removeChild( this.parentNode.element ); this.parentNode.parentNode.removeChild( this.parentNode ); this.parentNode.element.multi_selector.count--; this.parentNode.element.multi_selector.current_element.disabled = false; return false; }; var reduced; if (element.value.length > 25) { reduced = element.value.substr(0,25)+'...'; } else { reduced = element.value; } new_row.innerHTML = reduced; deletelink.appendChild(t); new_row.appendChild(deletelink); this.list_target.appendChild( new_row ); }; }; The input bit to look at in the javascript file is this.addElement = function( element ){ if( element.tagName == 'INPUT' && element.type == 'file' ){ element.name = 'file_' + this.id++; element.multi_selector = this; element.onchange = function(){ var new_element = document.createElement( 'input' ); new_element.type = 'file'; new_element.size = '45'; new_element.setAttribute('style', 'font:100% Verdana, Arial, Helvetica, sans-serif;'); this.parentNode.insertBefore( new_element, this ); this.multi_selector.addElement( new_element ); this.multi_selector.addListRow(this); this.style.position = 'absolute'; this.style.display = 'none'; This creates a new file input field, and deletes the hides the old one. So far, the email sender without attachments is this $to = "admin@developers-community.com"; $name = "$forename $surname - Guest"; $body = "$message\n\n $name"; $header = "from: $name <$email>"; mail($to, $subject, $body, $header); $to = $email; $name = "$forename $surname"; $email = "no-reply@developers-community.com"; $body = "Dear $name,\nThank you for your mail to us. Please wait patiently while we review it and get back to you. \nMeanwhile, You can use any of the other features within http://www.developers-community.com \n\n Your's Truly\nAdmin\nDeveloper's Community\n\nIn any case, do not reply to this email!"; $header = "from: Developers Community - Admin <$email>"; mail($to, $subject, $body, $header); echo '<span style="color:red";>Your mail has been sent.<br /> You will recieve a reply within up to 48 hours. This may take longer on busy days.<br /> You should have recieved an email stating we have recieved your mail, this may be in your Junk Folder.</span>'; Can anyone point me in the right right direction to sending the attachments? Thanks.
  5. Whats the element "i" What happens with what you have now? What is suppose to happen? I don't think you've explained well enough. What it looks like, you have a field, div whatever, and it's got an ID of "i" When you click it, it gives an alert. That's all I'm understanding right now.
  6. Are you trying to create the function with the value of "text" ?
  7. Thanks. Maybe I wasn't clear enough. If the string is bigger than 30 characters, to shorten it down to 30. Take away 3 and add "..." Thanks.
  8. var deletelink = document.createElement('a'); var t = document.createTextNode("X"); deletelink.setAttribute('href', '#'); deletelink.setAttribute('style', 'float:right;'); new_row.innerHTML = element.value; That code gets the value of the element, and puts it in a div. The last line is probably all you need, editting anything before that with the string will probably defeat the process. What I'm trying to do, is display a certain amount of characters. Lets say 30 for example. If the string is over 30, reduce by 3, and add "..." Or whatever will be possible. I know it's possible to do it with php, but not in the way I'm wanting to do it. "element.value" is the value, so maybe creating a var eg: var reduced = element.value.reduced to 30; new_row.innerHTML = reduced However, that's not correct. You may get the idea. Can anyone help? Thanks.
  9. MM_swapImage('Image11','','f',1) Whats the function you created for that? Also, whats the function for MM_swapimgRestore()
  10. if(document.getElementById('attachment')) { do whatever } else { add field } Although how do I get it so that if 2 fields exist,
  11. We'll need to view your function to see where to start from.
  12. It'd be a Hover too. EG: <style> <code> #mylink:hover { css for hover } </style> <a href="link.php" id="mylink">link</a> </code>
  13. I have a function, that when it's called it creates a File type input. I want it to create a file type input if there is not one there, so only 1 is aloud on a page at a time. - when onchange, it gets deleted, which means you can add another one. How can I do it? function addFileInput() { var d = document.createElement("div"); var file = document.createElement("input"); file.setAttribute("type", "file"); file.setAttribute("name", "attachment"); file.setAttribute("id", "attachment"); file.setAttribute("onchange", "document.getElementById('attachments').style.display = ''; deleteFileInput();"); d.appendChild(file); document.getElementById("attach").appendChild(d); upload_number++; }
  14. Have a radio button, value = yes. if(isset($_POST['submit'])){ $time = time() + 60*60*24*1000; // Length of time till cookie expires. if($_POST['radiobutton'] == 'yes'){ setcookie(cookie name, 'yes', $time); } else { setcookie(cookie name, 'no', $time); } } You should get the drift.
  15. http://www.lmgtfy.com/?q=open+save+as+dialog+box+with+php That may be your answer.
  16. It's all javascript, it doesn't make much sense to me. However, I had a go at creating something similar. http://developers-community.com/test.php <-- Thats what I've got so far. Click on "Attach" brings up a input, browse a file. Then the input disappears and a div gets displayed. Click on "Attach" and a blank new one gets displayed. The next thing I need to do is make it so that when onchange, it passes the file name. eg: filename.jpg over to the div in a seperate div, and they go underneath each other. Any ideas? Here is my code so far. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> var upload_number = 5; function deleteFileInput() { var att = document.getElementById("attach"); att.removeChild(att.childNodes[0]); } function addFileInput() { var d = document.createElement("div"); var file = document.createElement("input"); file.setAttribute("type", "file"); file.setAttribute("name", "attachment"+upload_number); file.setAttribute("id", "attachment"); file.setAttribute("onchange", "document.getElementById('attachments').style.display = ''; deleteFileInput();"); d.appendChild(file); document.getElementById("attach").appendChild(d); upload_number++; } </script> </head> <body> <a href="javascript:addFileInput();">Attach</a> <div id="attachments" style="width:150px; height:180px; border:1px solid #000; display:none;"> </div> <div id="attach"></div> </body> </html>
  17. I've seen file uploads that look different to that one. Would that be manually done? or what. I'm looking for a similar kind of attachment form like what hotmail uses. I can't find anything.
  18. <input type="file"> How do I customize this so I can have it to look the way I want. EG: With the submit button underneath, or whatever. I know this will end up seperate, and may need javascript, but can someone tell me how to do it?
  19. http://www.uploadify.com/demo/ The multiple file upload on there looks good. Although, how would I put it as an email attachment? The style does look good however with my contact form.. i'd like the files to be automatically uploaded instead of clicking the upload button, and without removing it when the file has uploaded. Then when a user clicks submit, to send the form- the files get sent with it. I'm not if uploading the images to the directory "uploads" would be used, because it might get mixed up. Unless when the file gets uploaded, the file name gets an id, and a session id gets created or what? I'm having a look at it now, but can you help me with that?
  20. Yes, that is perfect. I downloaded the files, but there is many files, opening index.html it just says "this has been moved to .. " with the link. I can't find the manual tutorial either. Can you help?
  21. Idea: http://www.flashcomponents.net/component/contact_form_mail_with_attachments.html You have to buy it, but the attachments on there, is a reasonable idea that I like, except with no flash.
  22. I've got a fully working contact form, and I've seen single email attachments which simply an input file. Although what I'm looking for is something like Hotmail. However the upload field stays there, you click browse find your file and click ok. That then disappears from the textbox, and ends up in a field above or wherever I wanted it to be. Also with a delete button. I have seen something similar to this but can't find it again. Does anyone have any tutorials, or a code they can provide for something like this?
  23. imagestring ($img_handle, 5, 20, 6, $sum, $color); How do I make it so the text is bolder, but not actually bigger? This then gets converted into an image too.
  24. Hmm.. I'm sorry. I didn't quite see it as a double post. Yeah sorry. That was a common typo I didn't notice.
  25. Parse error: syntax error, unexpected '=' in /home/jeanie/public_html/recaptcha/pngimg.php on line 51 sum = "$pri + $met ="; How do I solve it ?
×
×
  • 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.