gingank 0 Junior Poster

I need help from you guy to check what wrong with my code i headache and think few days also can not slove help pls. I need to create a more than one attachment file when other use my mail system . So how to do

Here is the code:

<?php
$to=stripslashes($_POST['to']);
if($to == '0'){
$to='@mail.com';
@mail($to, $subject, $body, $headers);
}else {
$to='@mail.com';
@mail($to, $subject, $body, $headers);
}

$from=$_REQUEST['from'];
if($from == '') {echo "<script langauge=\"javascript\">alert('You have not entered a Name, please go back fill up and try again!!')</script>";}
else {
$subject=$_REQUEST['subject'];

if($subject== '') {echo "<script langauge=\"javascript\">alert('You have not entered a Subject, please go back and try again!!')</script>";}
else {

$ip=$_POST['ip'];
$phone=$_REQUEST['phone'];
if($phone == '') {echo "<script langauge=\"javascript\">alert('You have not entered a Phone Ext, please go back fill up and try again!!')</script>";}
else {
$body=$_REQUEST['problem'];


$fields = array();
$fields{"from"} = "Name";
$fields{"email"} = "Email";
$fields{"phone"} = "Phone Ext";
$fields{"ip"}="IP Address";
$fields{"problem"} = "Request";

$body = "Here is the following detail:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }


$fileatt      = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

$fileatt      = $_FILES['fileatt2']['tmp_name'];
$fileatt_type = $_FILES['fileatt2']['type'];
$fileatt_name = $_FILES['fileatt2']['name'];

$fileatt      = $_FILES['fileatt3']['tmp_name'];
$fileatt_type = $_FILES['fileatt3']['type'];
$fileatt_name = $_FILES['fileatt3']['name'];

$headers = "From: $from";

if (is_uploaded_file($fileatt)) {
 
  $file = fopen($fileatt,'rb');
  $data = fread($file,filesize($fileatt));
  fclose($file);


  $semi_rand = md5(time());
  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  
 
  $headers .= "\nMIME-Version: 1.0\n" .
              "Content-Type: multipart/mixed;\n" .
              " boundary=\"{$mime_boundary}\"";


  $body = "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" .
             $body . "\n\n";

 
  $data = chunk_split(base64_encode($data));


  $body .= "--{$mime_boundary}\n" .
              "Content-Type: {$fileatt_type};\n" .
              " name=\"{$fileatt_name}\"\n" .
           
              "Content-Transfer-Encoding: base64\n\n" .
              $data . "\n\n" .
              "--{$mime_boundary}--\n";
}



$ok = @mail($to, $subject, $body, $headers);
if ($ok) {
  echo "<p>Thank you for using the system. Your request have been sent. We will get back to you soon !</p>";
} else {
  echo "<p>Mail could not be sent. Sorry! Please Try it Later</p>";
}
}
}
}




?>