Hi Everyone!

I'm pretty darn new to PHP, and I've built and email form in Dreamweaver. Basically, it will just submit the form information to a set email address once it's filled out. However, there are two problems...

1: When the code is set up like this, everything works great but when the info comes through in the email, the information comes all squished together with no breaks (addressphoneposition)

$message = "Message from: $from\n\n".stripslashes($_POST['address']).stripslashes($_POST['phone']).stripslashes($_POST['position']);

2: I would like the emailed information to have page breaks so it's not so confusing to look at. I've done a little research and gotten some feedback that seems really helpful, but when I put the revised code in, the web page comes up completely blank with no source code.

$message = "Message from: $from\n\n".stripslashes($_POST['address'])."\n".stripslashes($_POST['phone'])"\n".stripslashes($_POST['position']);

I'm at a bit of a loss... people have mentioned that I should have error reporting on, but I'm honestly embarrassed to say that I'm not sure how to do this in Dreamweaver... sigh

If anyone has any suggestions, I would appreciate it to no end... Thanks so much for reading, and here is the full code of the document, just in case!

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


   $to="bad@php.com";

   $subject="Resume Submittion";


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


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


   $tmp_name = $_FILES['filename']['tmp_name'];
   $type = $_FILES['filename']['type'];
   $name = $_FILES['filename']['name'];
   $size = $_FILES['filename']['size'];


   $message = "Message from: $from\n\n".stripslashes($_POST['address'])."\n".stripslashes($_POST['phone'])"\n".stripslashes($_POST['position']);

   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));
 }


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


  $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";


  $message .= "--{$mime_boundary}\n" .
     "Content-Type: {$type};\n" .
     " name=\"{$name}\"\n" .

     "Content-Transfer-Encoding: base64\n\n" .
     $data . "\n\n" .
     "--{$mime_boundary}--\n";


  if (@mail($to, $subject, $message, $headers))
     echo "Message Sent";
  else
     echo "Failed to send";
   }
} else {
?>
<p>Send an e-mail with an attachment:</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" 
   enctype="multipart/mixed" name="form1">
   <p>Name: <input type="text" name="fromname"></p>
   <p>Address: <input type="text" name="address"></p>
   <p>Phone: <input type="text" name="phone"></p>
   <p>E-mail: <input type="text" name="fromemail"></p>
   <p>Position: <input type="text" name="position"></p>
   <p>File: <input type="file" name="filename"></p>
   <p><input type="submit" name="Submit" value="Submit"></p>
</form>
<?php } ?>

    Sheena

    In your message you have $from\n. PHP thinks that $from\n is a variable name. You should separate the two and take the variable out of the string.

    Try this:

    $message = "Message from: " . $from . "\n\n". stripslashes($_POST['address']) . "\n\n" . stripslashes($_POST['phone']) . "\n\n" . stripslashes($_POST['position']);
    
    /*That should break your message up more so it is easier to read. */
    
    

      Brendan,
      Oh... my... God...

      You are my hero... you have no idea how long I have been struggling with this!!! Ha ha ha! You are absolutely fantastic! Thank you so much for taking the time to help me with this! You can't imagine how much I appreciate it!!!!
      <3
      -Sheena

        You are very welcome. If that was your only question please mark this resolved.

          brendan2b wrote:

          In your message you have $from\n. PHP thinks that $from\n is a variable name.

          Er, no it doesn't. Variable names can't contain linebreak characters. The problem is further along:

          stripslashes($_POST['phone'])"\n"

          With no . between the stripslashes() and the "\n", the latter is unexpected and PHP fails with a parse error (clearly, error reporting has been turned off, hence the blank screen).

            Write a Reply...