Jump to content

jtesolin

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jtesolin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have been working on testing this code for wahile and have everything working excpt teh selct boxes. I am not sure of what is causing the problem. The php /html code is below. Some html elements are cut out. Some useful info below: a) Your PHP version, platform (operating system), and webserver : PHP 4 /windowes webserver: Xampp B) Your hosting company: localhost c) Pertinent php.ini settings (SafeMode=On, for example).: included in code. otherwise default d) Error messages if any are generated: none. e) Code snippets, enclosed in the php bbcode tags: [code] <?php //set ini variables to override php.ini fo rthis form ini_set("SMTP","localhost"); ini_set("sendmail_from","jtesolin@localhost");   if ($_SERVER['REQUEST_METHOD'] != 'POST'){       $form_send = $_SERVER['PHP_SELF']; ?> <form action="<?php echo $form_send;?>" method="post" enctype="multipart/form-data" name="request">   <p><table border="0" width="400" cellspacing="0" cellpadding="0"> <tr> <td width="100">Title:</td> <td><input type="text" name="u_title" value="" /></td> </tr> <tr>   <td width="100">Date Required:</td>   <td><input type="text" name="u_date" value="" /></td>     </tr> <tr>   <td width="100">Address</td>   <td><input type="text" name="u_address" value="" /></td>     </tr> <tr>   <td width="100">Contact Name:</td>   <td><input type="text" name="u_contact" value="" /></td>     </tr> <tr>   <td width="100">Contact Email:</td>   <td><input type="text" name="u_email" value="" /></td>     </tr> </table> </p> <p><table width="500" border="0" cellspacing="0" cellpadding="0">   <tr>     <td>Attachment 1<br /> <input type="hidden" name="MAX_FILE_SIZE" value="5000000" /> <input name="file1" type="file" /></td>     <td>Attachment 2<br /> <input name="file2" type="file" /></td>   </tr>   <tr>   <td colspan="2">Who is this file for? Please hold cntrl button to select both advisor and investor.</td>   </tr>   <tr>     <td><select name="for_file1[]" multiple="multiple" id="for_file1">               <option value="investor1">Investors</option>               <option value="advisors1">Advisors</option>             </select> </td>     <td><select name="for_file2[]" multiple="multiple" id="for_file2">               <option value="investor2">Investors</option>               <option value="advisors2">Advisors</option>             </select> </td>   </tr> </table> </p> <p>Comments:<br /> <textarea cols="100" rows="10" name="u_comments" wrap="physical">Please enter comments here.</textarea> </p> <p><input type="submit" name="submit" value="submit" /><input type="reset" value="reset" name="reset" /></p> </form> <?php   } else {   // assign variables $to="jtesolin@localhost"; $subject="New E-Business Request"; $u_title = $_POST['u_title']; //title of request document $u_date = $_POST['u_date']; //date required $u_address = $_POST['u_address']; //address where web site is located $a_contact = $_POST['u_contact']; //contact Name $u_email = $_POST['u_email']; //contact email $a_comments = $_POST['u_comments']; //contact u_comments $from = stripslashes($_POST['u_contact'])."<".stripslashes($_POST['u_email']).">";   // generate a random string to be used as the boundary marker   $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";   //build body hheaders   $headers = "From: $from\r\n" .   "MIME-Version: 1.0\r\n" .   "Content-Type: multipart/mixed;\r\n" .   " boundary=\"{$mime_boundary}\"";   // start of text to be displayed in email $body="From: $a_contact \r\n"; $body.="Email: $u_email \r\n"; $body.="Message: $a_comments \r\n"; $body.="Title of Document: $u_title \r\n"; $body.="URL of update: $u_address \r\n"; $body.="Date Required: $u_date \r\n"; //advisor or investor doc -file 1? if ($for_file1){             for ($h=0;$h<count($for_file1);$h++)               $body.= "Document 1 is for: \n";   $body.= "\n- $for_file1[$h] \n";         }else{             $body.="\n- None"; } //advisor or investor doc -file 2? if ($for_file2){             for ($i=0;$i<count($for_file2);$i++)               $body.= "Document 2 is for: \n";   $body.= "\n- $for_file2[$i] \n";         }else{             $body.="\n- None"; }   // invisible portion of messege body   $body = "This is a multi-part body in MIME format.\n\n" .   "--{$mime_boundary}\n" .   "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .   "Content-Transfer-Encoding: 7bit\n\n" .   $body . "\n\n";   // process the  uploaded files   foreach($_FILES as $userfile){   // store the file information to variables for easier access   $tmp_name = $userfile['tmp_name'];   $type = $userfile['type'];   $name = $userfile['name'];   $size = $userfile['size'];   // 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)); } // boundary indicates start of the attachment // we have to specify the content type, file name, and disposition as // an attachment, then add the file content. $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";   }   }   //mime boundary indicates the last of the body   $body.="--{$mime_boundary}--\n";   // now we just send the body if (empty($u_title) || empty($u_date) || empty($u_address) || empty($a_contact) || empty($u_email) || empty($a_comments)) { echo "<p><strong>Please enter the following information:</strong></p>"; } if ($u_title == "") { echo "The title is a required field<br />"; } if($u_date == ""){ echo "Please specify the date that your request should be due by<br />"; } if($u_address == ""){ echo "The website address where the update file is located is a required field.<br />"; } if(u_email == ""){ echo "Please enter your email address"; } if($a_contact == ""){ echo "In order to complete your request we must have your name<br />"; } if($a_comments == ""){ echo "To better fulfil your request we need some information.<br />"; } if ($u_title == ""){ echo "<p>Please press the back button and fill in the form again</p>"; }elseif($u_date == ""){ echo "<p>Please press the back button and fill in the form again</p>"; }elseif($u_address == ""){ echo "<p>Please press the back button and fill in the form again</p>"; }elseif($a_contact == ""){ echo "<p>Please press the back button and fill in the form again</p>"; }elseif($a_comments == ""){ echo "<p>Please press the back button and fill in the form again</p>"; }else{   if (@mail($to, $subject, $body, $headers))   echo nl2br("<strong>Details of Request:</strong> Title: $u_title<br /> Date Required: $u_date<br /> Website Address: $u_address<br /> Contact name: $a_contact<br /> Contact email: $u_email");   else   echo "Failed to send"; } } ?> [/code]
×
×
  • 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.