Jump to content

Recommended Posts

Hi everyone!

 

Well... I'm incredibly new to php, so please bare with me!  I'm doing up a little form which emails the information to an account.  Everything seems to be going great and submitting properly, however when the information is submitted it comes up looking like this:

 

"addressphoneposition"

 

I'm curious if there is a way that I can manipulate that code to put a page break between the values.  It's probably something extremely simple, but I'm really so new to this that I don't even know where to begin.

 

Any suggestions would be fantastic and I would really appreciate it!

Thank you so much!

 


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

   
   $to="not-good@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']).stripslashes($_POST['phone']).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 } ?>
</body>
</html>
                     

Link to comment
https://forums.phpfreaks.com/topic/51842-trouble-with-php-form/
Share on other sites

When you use the "." operator to concatenate values, you need to explicitly put any spaces, so instead of:

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

you would write

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

 

Ken

 

Link to comment
https://forums.phpfreaks.com/topic/51842-trouble-with-php-form/#findComment-255475
Share on other sites

you would write

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

 

Ken

 

 

Thank you, Ken!  However, when I place that, for some reason the page will not show any of the content after I upload it... hmmmm... I must be doing something wrong here.  :(

Link to comment
https://forums.phpfreaks.com/topic/51842-trouble-with-php-form/#findComment-255490
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.