mam pewien problem ze skryptem formularzu kontaktowego. Otóż mam ten skrypt:
<?php include_once('config.php'); include_once('functions.php'); //If contact is being sent: if($_POST['submit_id'] == 1){ //Check name entered if($_POST['name'] == NULL){ $message = 'Please enter your name.';} //check if email is enetered if($message == NULL && is_valid_email($_POST['email']) == false ){ $message = 'Please enter a valid email.';} //check if message is entered if($_POST['message_text'] == NULL && $message == NULL){ $message = 'Please enter a comment.';} //File Upload checks if($message == NULL && $FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ if($_FILES['user_file']['size'] > (($FILE_UPLOAD_MAX*1024)*1024)){ $message = 'File is over '.$FILE_UPLOAD_MAX.' MB in size.';} if($message == NULL && allowed_ext($FILE_UPLOADS_EXT,$_FILES['user_file']['name']) == false){$message = 'Invalid extension.';} } //Image verificaiton checks if($message == NULL && $IMAGE_VERIFICATION == 1){ $te_co = hex2bin($_POST['hid_code']); $word_is = RC4($te_co,$IMAGE_VER_CODE); if($word_is != $_POST['confirm_image']){$message = 'Your verfication code is incorrect.';} } //End verifications, start processing if($message == NULL){ //Check if file upload is needed if($FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ //Store file for keep and email } //compose admin/user message templates replaces //Send user email? if($SEND_THANKS == 1){ //Set Headers $user_header = "Return-Path: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $user_header .= "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $user_header .= "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=".$EMAIL_OPTIONS['CHARSET'].";\n\n\r\n"; //Send Thank you } //Send admi email? //Do we need to send file as attachment? if($FILE_DO != 1){ //Get file attriubtes $fileatt_type = $_FILES['user_file']['type']; $attachment_data .= $dat; } // Encode file content //File upload headers $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">"; // 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 $new_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=\"".$EMAIL_OPTIONS['CHARSET']."\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $admin_message . "\n\n"; // Add file attachment to the message $new_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$new_filename}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$new_filename}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $attachment_data . "\n\n" . "--{$mime_boundary}--\n"; } else { //regular headers $headers = "Return-Path: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $headers .= "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $headers .= "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=".$EMAIL_OPTIONS['CHARSET'].";\n\n\r\n"; $new_message = $admin_message; } //Send admin emails foreach($ADMIN_EMAILS as $this_email){ } } //Remove file if not needed if($FILE_DO == 2){ } $message = 'Your contact has been sent, thank you.'; $_POST = NULL; } } if($message != NULL){ ?> <table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FF8080"> <tr> <td bgcolor="#FFD5D5"><font color="#FF0000"><?=$message;?></font></td> </tr> </table> <br/> <?php } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="contact" id="contact" style="display:inline;"> <table width="100%" border="0" align="left" cellpadding="5" cellspacing="0"> <tr> <td>Name:</td> </tr> <tr> <td>Email:</td> </tr> <tr> <td>Reason for contact: </td> <td><select name="reason" id="reason" style="width:154px;"> <?php if($_POST['reason'] == 'Support' || $_POST['reason'] == NULL){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Support"<?=$sel;?>>Support</option> <?php if($_POST['reason'] == 'Billing'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Billing"<?=$sel;?>>Billing</option> <?php if($_POST['reason'] == 'Complaints'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Complaints"<?=$sel;?>>Complaints</option> <?php if($_POST['reason'] == 'Other'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Other<?=$sel;?>">Other</option> </select></td> </tr> <tr> <td>Message:</td> <td><textarea name="message_text" cols="40" rows="4" id="message_text"><?php echo $_POST['message_text'];?></textarea></td> </tr> <?php if($IMAGE_VERIFICATION == 1){?> <tr> <td>Verification code:</td> <td> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php //Generate the random string "K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v", "V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9"); $length = 8; $textstr = ""; for ($i=0; $i<$length; $i++) { } $new_string = RC4($textstr,$IMAGE_VER_CODE); ?> <img src="sec_image.php?code=<?=$image_link;?>"> <input name="hid_code" type="hidden" id="hid_code" value="<?=$image_link;?>"><br/> <input name="confirm_image" type="text" id="confirm_image" value="<?php echo $_POST['confirm_image'];?>"></td> </tr> </table> </td> </tr> <?php } if($FILE_UPLOAD == 1){?> <tr> <td>File Upload </td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input name="user_file" type="file" id="user_file"></td> </tr> <tr> <td><font color="#FF0000" size="2">Max. File Size: <?=$FILE_UPLOAD_MAX;?> MB, Allowed Extensions: <?php </font></td> </tr> </table> </td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Send Contact"> <input name="submit_id" type="hidden" id="submit_id" value="1"> </div></td> </tr> <?php } ?> <tr> <td colspan="2"><div align="left"><a href="http://www.free-php-scripts.net" target="_blank"><font size="1">Powered by Simple Contact </font></a></div></td> </tr> </table> </form> ?>
i moje pytanie: jak go przerobić aby wysyłał dwa załączniki? Męczę się nad tym od dobrych 10 godzin i już dostaję białej gorączki. Czytałem różne poradniki, z manualem php włącznie. Wiem, że muszę zastosować
<td><input name="user_file[]" type="file" id="user_file"></td>
ale co dalej? Może ktoś mi pomóc? Będę bardzo wdzięczny.