darkfreaks Posted August 6, 2012 Share Posted August 6, 2012 so i got my attachment upload to work by putting encype multipart boundary in my form. however it stopped sending all my post data in the header. is there a certain reason why it would do this Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/ Share on other sites More sharing options...
cpd Posted August 6, 2012 Share Posted August 6, 2012 There is no such enctype "multipart". Its "multipart/form-data", "text/plain" or another one that's really long and I can't remember but is default anyway. Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367258 Share on other sites More sharing options...
darkfreaks Posted August 6, 2012 Author Share Posted August 6, 2012 enctype = content-type [CI] This attribute specifies the content type used to submit the form to the server (when the value of method is "post"). The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file". ^ but like i said using multipart/form-data makes it to where the $message in the email no longer shows up it is just the image. Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367260 Share on other sites More sharing options...
cpd Posted August 6, 2012 Share Posted August 6, 2012 You misunderstood my point. I thought you had enctype="multipart" which is invalid. Have you tried running var_dump($_POST);? Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367272 Share on other sites More sharing options...
darkfreaks Posted August 6, 2012 Author Share Posted August 6, 2012 i get a blank array tried to fill it out to see what it gives me but it just emails a blank array i guess. Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367280 Share on other sites More sharing options...
Mahngiel Posted August 6, 2012 Share Posted August 6, 2012 gonna have to see the relevant data Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367284 Share on other sites More sharing options...
darkfreaks Posted August 6, 2012 Author Share Posted August 6, 2012 relevant php code: if (isset($_POST['submit'])){ $name="walpole-group.co.uk"; $to = "[email protected]"; //$to = "[email protected]"; /* subject */ $subject = "Walpole Group Male Application Form"; /* $uid=md5(uniqid(time())); html encoding unique id $headers = "--".$uid."\r\n"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers.="Content-Transfer-Encoding: 7bit\r\n\r\n"; $headers.=$message."\r\n\r\n"; */ foreach($_POST as $key => $val){ $_POST[$key] = trim($val); } $comDisplay12 =(isset($_POST['radio1']) && $_POST['radio1']=="Yes" ? " Yes " : " - "); $comDisplay13 =(isset($_POST['radio2']) && $_POST['radio2']=="Yes" ? " Yes " : " - "); $comDisplay14 =(isset($_POST['radio3']) && $_POST['radio3']=="Yes" ? " Yes " : " - "); $comDisplay16 =(isset($_POST['piercings']) && $_POST['piercings']=="Yes" ? " Yes " : " - "); $comDisplay17 =(isset($_POST['tattoos']) && !empty($_POST['tattoos']) ? $_POST['tattoos'] : " - "); $comDisplay18 =(isset($_POST['checkbox']) && !empty($_POST['checkbox']) ? $_POST['checkbox'] : " - "); $comDisplay19 =(isset($_POST['checkbox2']) && !empty($_POST['checkbox2']) ? $_POST['checkbox2'] : " - "); $comDisplay20 =(isset($_POST['checkbox3']) && !empty($_POST['checkbox3']) ? $_POST['checkbox3'] : " - "); $comDisplay21 =(isset($_POST['checkbox4']) && !empty($_POST['checkbox4']) ? $_POST['checkbox4'] : " - "); $comDisplay21a =(isset($_POST['checkbox5']) && !empty($_POST['checkbox5']) ? $_POST['checkbox5'] : " - "); $comDisplay22 =(isset($_POST['checkbox6']) && !empty($_POST['checkbox6']) ? $_POST['checkbox6'] : " - "); $comDisplay23 =(isset($_POST['checkbox7']) && !empty($_POST['checkbox7']) ? $_POST['checkbox7'] : " - "); // if not empty file upload field if(!empty($_FILES['file_upload']['name'])) { $file_name = "{$_FILES['file_upload']['name']}"; $tmp_name = "{$_FILES['file_upload']['tmp_name']}"; $file_type = "{$_FILES['file_upload']['type']}"; // get extension of file $base = basename($file_name); //$ext = substr($base,strlen($base)-4, strlen($base)); $ext = pathinfo($base, PATHINFO_EXTENSION); //allowed extensions $allowed_ext= array('jpeg','jpg','gif','png'); //check if allowed extension if(in_array($ext,$allowed_ext)){ $file=$tmp_name; $content=chunk_split(base64_encode(file_get_contents($file))); $uid= md5(uniqid(time())); //declarinf mutlipart boundary type $headers= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n"; $headers.="this is a message in multipart MIME format.\r\n"; //file attachment $headers .= "--".$uid."\r\n"; $headers.="Content-Type:".$file_type."; name=\"".$file_name."\"\r\n"; $headers.="Content-Transfer-Encoding: Base64\r\n"; $headers.="Content-Disposition: attachment; filename=\"".$tmp_name."\"\r\n"; $headers.=$content."\r\n\r\n"; }else{ $error="File Type Not Allowed!"; } }else{ $error="No File Uploaded!"; } if (!isset($error)){ $strBody="<table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#000000 >"; $strBody=$strBody."<tr><td valign=top><table width=710 cellpadding=0 cellspacing=0 border=0 bordercolor=#FFFFFF>"; $strBody=$strBody."<tr><td colspan=2 ><font size=3 face=Verdana, Arial, Helvetica, sans-serif color=#FFFFFF><strong>Walpole Group Male Application Form</strong></font><br></td><td> </td></tr>"; $strBody=$strBody."</tr><tr><td colspan=3><hr align=center width=100% size=1 noshade color=#3C4B86></td>"; //======================model contact info======================================= $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Model's Information</b></font></td><td> </td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Stage Name:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["stageName"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>First Name:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["firstName"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Surname:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["surName"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>N I No:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["niNo"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Date of birth:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["dob"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Age:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["age"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Star sign:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["star"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Address 1:</font></td>"; $strBody=$strBody."<td width = 201 colspan=2><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["address1"])." </font></td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Address 2:</font></td>"; $strBody=$strBody."<td width = 201 colspan=2><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["address2"])." </font></td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Address 3:</font></td>"; $strBody=$strBody."<td width = 201 colspan=2><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["address3"])." </font></td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Town/City:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["town"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Postcode:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["postcode"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>States:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["states"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Home Telephone No:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["homeNo"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Mobile Telephone No:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["mobileNo"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Email Address:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["email"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Web Address:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["webAddress"])." </font></td><td> </td>"; //=====================model physical info======================================== $strBody=$strBody."</tr><tr><td colspan=3><hr align=center width=100% size=1 noshade color=#3C4B86></td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Physical Descriptions</b></font></td><td> </td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Height:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["height"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Weight:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["weight"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Suit size:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["suitSize"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Shoe size:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["shoeSize"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Chest size:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["chestSize"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Waist Size:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["waistSize"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Leg Size:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["legSize"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Hair color:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["hairColor"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Length:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["length"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Eyes color:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["eyesColor"])." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Complexion:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["complexion"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Ethnic origin:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["ethnicOrigin"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Other info:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Do you smoke:".$comDisplay12."<BR>Do you drink:".$comDisplay13."<BR>Do you drive:".$comDisplay14."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Piercings:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".$comDisplay16." </font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Tattoos:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".$comDisplay17." </font></td><td> </td>"; //======================model attributes============================================== $strBody=$strBody."</tr><tr><td colspan=3><hr align=center width=100% size=1 noshade color=#3C4B86></td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Model's attributes</b></font></td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Work undertaken</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Fashion:".$comDisplay18."</td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Swimwear:".$comDisplay19."</td></font></tr> "; $strBody=$strBody."<tr><td> </td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Nude:".$comDisplay20."</font></td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Boy / Girl Soft:".$comDisplay21."</font></td></tr>"; $strBody=$strBody."<tr><Td> </td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Boy / Girl XXX:".$comDisplay21a."</font></td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Stills:".$comDisplay22."</font></td></tr>"; $strBody=$strBody."<tr><Td> </td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Video:".$comDisplay23."</font></td><td> </td></tr>"; $strBody=$strBody."</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Previous experiences:</font></td>"; $strBody=$strBody."<td colspan=2 width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["experience"])." </font></td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Introduce By:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["introduceBy"])."</font></td><td> </td>"; $strBody=$strBody."</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Date:</font></td>"; $strBody=$strBody."<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["dateTime"])."</font></td><td> </td>"; //======================model related info============================================ $strBody=$strBody."</tr><tr><td colspan=3> </td></tr></table>"; $message=$strBody; mail($to, $subject, $message, $headers); header("Location: thankyou.php"); exit; } } if i can get BOTH the $_FILE and $_POST arrays to work would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367287 Share on other sites More sharing options...
darkfreaks Posted August 6, 2012 Author Share Posted August 6, 2012 did some research it said if you use enctype multi-part/form-data that it clears the POST array is this correct? and how do i prevent this. Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367292 Share on other sites More sharing options...
darkfreaks Posted August 6, 2012 Author Share Posted August 6, 2012 i tried making $message text/html did not work neither did putting $message in the $header then making it text/html anyone got any ideas on how to show html messages with multipart form data? Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367319 Share on other sites More sharing options...
darkfreaks Posted August 6, 2012 Author Share Posted August 6, 2012 solved i changed the headers abit and restructured the code. to make the file upload a seperate part of the code. Quote Link to comment https://forums.phpfreaks.com/topic/266742-mail-help/#findComment-1367335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.