Jump to content


form mail won't receive information from select/list boxes.

  • Please log in to reply
No replies to this topic

#1 jtesolin

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 September 2006 - 09:57 PM

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:

//set ini variables to override php.ini fo rthis form
      $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">
		<td width="100">Title:</td>
		<td><input type="text" name="u_title" value="" /></td>
	  <td width="100">Date Required:</td>
	  <td><input type="text" name="u_date" value="" /></td>
	  <td width="100">Address</td>
	  <td><input type="text" name="u_address" value="" /></td>
	  <td width="100">Contact Name:</td>
	  <td><input type="text" name="u_contact" value="" /></td>
	  <td width="100">Contact Email:</td>
	  <td><input type="text" name="u_email" value="" /></td>

<p><table width="500" border="0" cellspacing="0" cellpadding="0">
    <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>
  <td colspan="2">Who is this file for? Please hold cntrl button to select both advisor and investor.</td>
    <td><select name="for_file1[]" multiple="multiple" id="for_file1">
               <option value="investor1">Investors</option>
               <option value="advisors1">Advisors</option>
    <td><select name="for_file2[]" multiple="multiple" id="for_file2">
               <option value="investor2">Investors</option>
               <option value="advisors2">Advisors</option>

<p>Comments:<br />
<textarea cols="100" rows="10" name="u_comments" wrap="physical">Please enter comments here.</textarea>

<p><input type="submit" name="submit" value="submit" /><input type="reset" value="reset" name="reset" /></p>
   } else {
	   // assign variables
		$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
	  //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";
            $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";
            $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
				// 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
				// 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
	   // 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>";
	   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");
		  echo "Failed to send";

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users