Jump to content

Need help please. Email form


petonii

Recommended Posts

Hello guys,

 

I got everything working in this form, i can send attachments everything is sweet, but i want to add additional information like phone numbers and names. But i can't seem to figure out where to add the code. my mate helped me with this, thats why i can't figure it out and he has gone on holidays. PLEASE HELP! i been trying for over 3 hours.

 

Ill show both the PHP and HTML of the code

 

<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){

   $to="email@email.com";
   $subject="email requested";


   $from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">";
   

   $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";


   $headers = "From: $from\r\n" .
   "MIME-Version: 1.0\r\n" .
      "Content-Type: multipart/mixed;\r\n" .
      " boundary=\"{$mime_boundary}\"";

   $message=($_POST['fromdesc']);

   $message = "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" .
   $message . "\n\n";
   
   foreach($_FILES as $userfile){

      $tmp_name = $userfile['tmp_name'];
      $type = $userfile['type'];
      $name = $userfile['name'];
      $size = $userfile['size'];

      if (file_exists($tmp_name)){

         if(is_uploaded_file($tmp_name)){

            $file = fopen($tmp_name,'rb');

            $data = fread($file,filesize($tmp_name));

            fclose($file);

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

         $message .= "--{$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";
      }
   }
   $message.="--{$mime_boundary}--\n";

   if (@mail($to, $subject, $message, $headers))
      echo "It worked.";
   else
      echo "Failed to send";
} else {
?>

 

 

 

And now HTML

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>



<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" 
   enctype="multipart/form-data" name="form1">
             
              <table width="100%" border="0">
                <tr> 
                  <td height="55"><font size="+1" face="Arial, Helvetica, sans-serif"><strong> 
                    </strong></font> 
                    <input type="text" name="fromname"> <font size="+1" face="Arial, Helvetica, sans-serif"><strong> 
                    </strong></font></td>
                </tr>
                <tr> 
                  <td height="48"><input type="text" name="fromemail">
                  </td>
                </tr>
                <tr> 
                  <td height="52"><input type="text" name="businessname"></td>
                </tr>
                <tr> 
                  <td height="53"><input type="text" name="website">
                  </td>
                </tr>
                <tr> 
                  <td height="50"><input type="text" name="address"> </td>
                </tr>
                <tr> 
                  <td height="46"><input type="text" name="phone">
                  </td>
                </tr>
                <tr> 
                  <td height="52"><input type="text" name="email">
                  </td>
                </tr><tr> 
                  <td height="48"><input type="file" name="file1"></td>
                </tr><tr> 
                  <td height="48"><input type="file" name="file2"></td>
                </tr><tr> 
                  <td height="48"><input type="file" name="file3"></td>
                </tr><tr> 
                  <td height="48"><input type="file" name="file4"></td>
                </tr>
                <tr> 
                  <td height="208"><textarea name="fromdesc" cols="40" rows="10" id="textarea2"></textarea>
                  </td>
                </tr>
                <tr>
                  <td><input type="submit" name="Submit" value="Submit">
                    <font size="+1" face="Arial, Helvetica, sans-serif"><strong> 
                    <?php } ?>
                    </strong></font></td>
                </tr>
              </table>
              </form>
</body>
</html>

 

 

Any input would be great, i added the extra text fields in the HTML code but cant get the information to send to the email address.

Link to comment
Share on other sites

well it kinda depends what you want to do with the name and phone number.  either way, though, you are going to want to add the inputs to the html form.

 

Now, if you want to add these forms to the subject, before you send the email, do this:

$subject .= $_POST['cli_name'];
$subject .= $_POST['cli_phnum'];
...

 

if you want to add them to the body...

there is a line in the php where he says "$message = $_POST['fromdesc'];"

right after that line is where you want to add your fields, in whatever format you choose.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.