c-o-d-e Posted January 7, 2010 Share Posted January 7, 2010 I made a test with this PHP code I have to send attachments. It works the way I want it to, perfectly. I put the code in with my contact form, changed the necessary parts. Saved it, uploaded the file. Filled it out, click send. The form sends, but no attachments get sent. I've compared both forms, the tested one and the contact form. I can't seem to find the problem. I'm assuming something is stopping the form from sending attachments. Though what is it? Cany anyone help me? Here is the whole file, instead of posting the form and the php, it's the whole file. Incase its something else where attacking it. If you need anymore pages of code (includes maybe) Let me know. I'll update the post. Here's the form <?php session_start(); include ("inc/config.php"); include("inc/functions.php"); checkcookie(); ?> <!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" /> <meta http-equiv="Content-Language" content="en-UK" > <meta name="description" content="Developer's Community is a community dedicated to learning and teaching specific areas around computer development. We have a wide range of tutorials that cover all topics and we also have support forums for those who are needing a bit of support. The forums also consists of freelancing, and general discussions." > <title>Developer's Community - Contact Us</title> <link href="styles/main.css" rel="stylesheet" type="text/css" /> <link href="styles/support.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="images/favicon.ico"> <link rel="icon" href="images/favicon.ico"> <script type="text/javaScript" src="inc/cona.src.js"></script> <script src="multifile.js"></script> <?php background(); ?> <script type="text/javaScript" src="../inc/cona.src.js"></script> <script type="text/javascript"> image = "inc/pngimg.php" function Start() { tmp = new Date(); tmp = "?"+tmp.getTime() document.images["captcha"].src = image+tmp } </script> </head> <body> <!-- Begin Page --> <div id="container"> <!-- Header --> <div id="header"> <?php members_template(); ?> </div> <!-- Navigator --> <div class="navigator" id="dropdown"> <ul id="topnav"> <li><a href="/">Home</a></li> <li><a href="about.php">About</a></li> <li><a href="tutorials.php" rel="tutorials">Tutorials</a></li> <li class="active"><a href="support.php" rel="support">Support</a></li> <li><a href="forums">Forums</a></li> <li><a href="feeds">Feeds</a></li> </ul> </div> <?php navigator(); ?> <script type="text/javascript"> cssdropdown.startchrome("dropdown") </script> <div id="subnavigation"></div> <!-- Main Content --> <div id="pageContent"> <div id="advertskyscraper"> <script type="text/javascript"><!-- google_ad_client = "pub-7463512441958618"; /* 160x600, created 03/01/10 */ google_ad_slot = "6049830800"; google_ad_width = 160; google_ad_height = 600; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div> <div id="fill"> <h1>Contact Us</h1> <span>If you are in need in contacting Developer's Community then do so using the form below. If you are not a registered member or not logged in then you will need to fill in a Captcha field to confirm you are a human-being.</span><br /> <br /> <div style="margin-left:30px; border:1px solid #fff; margin-right:30px;"> <?php if($_SESSION['s_logged_n']){ echo "Currently you are required to be logged out to use the contact us form. This is a temporarily solution."; } else { 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)){ $to = "[email protected]"; $name = "$forename $surname - Guest"; $from = stripslashes($name)."<".stripslashes($email).">"; $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $header = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; $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".$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)); } $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"; $mail = mail($to, $subject, $message, $header); if(isset($mail)){ $to = $email; $name = "$forename $surname"; $email = "[email protected]"; $message = "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, $message, $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>'; } } ?> <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 <?php $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 <?php echo $error['email']; ?><br /> <input name="email" type="text" id="email" value="" <?php echo $_POST['email']; ?>"" size="50" class="textboxsup"/><br /> <span style="color: #F00">*</span>Subject <?php echo $error['subject']; ?><br /> <input name="subject" type="text" id="subject" value=""<?php echo $_POST['subject']; ?>"" size="50" class="textboxsup"/><br /> Add An Attachment (optional)<br /> <input id="my_file_element" type="file" name="file_1" size="45" style="font:100% Verdana, Arial, Helvetica, sans-serif;"></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 <?php echo $error['message']; ?></td></tr> <tr> <td><textarea name="message" cols="90" rows="12" class="textboxsup" id="message" value=""<?php echo $_POST['message']; ?>""></textarea></td> </tr> <tr> <td><span style="color: #F00">*</span>Verfication<span style="width:149px;"> (Are you human?) <?php echo $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> <center><?php } ?></div> <br /> <br /> <br /> <br /> <br /> <br /> </div> </div> <!-- Footer --> <div id="footer"> <?php footer(); ?> </div> <!-- end Page --></div> <?php include_once("inc/analytics.php") ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/187637-something-is-blocking-my-attachments-from-sending/ Share on other sites More sharing options...
c-o-d-e Posted January 7, 2010 Author Share Posted January 7, 2010 Sorry for bumping, this is a serious issue. I have no idea on the problem. Can someone please, please help me?! Link to comment https://forums.phpfreaks.com/topic/187637-something-is-blocking-my-attachments-from-sending/#findComment-990687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.