Line break not working well

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Easytime
    New Member
    • Nov 2012
    • 26

    Line break not working well

    Big Brothers, Please kindly help me out on this....
    I assigned values to a series of variables.
    I tried to read out these values with linebreaks, but the line breaks aren't working as expected.

    I am sending a mail to an address:
    The problem is, if I check the mail, the mail object does not strip-format the linebreaks. It adds the linebreaks together with the values.
    Pls see the code below:
    Code:
    <?php 
    if (empty($_POST) === false) {
    	$errors = array();
    
            $name = $_POST['name'];
    	$email = $_POST['email'];
    	$mess = $_POST['description'];
    	$cname=$_POST['company'];
    	$add=$_POST['address'];
    	$tel=$_POST['phone'];
    	$product=$_POST['prtype'];
    	$qty=$_POST['quantity'];
    	$comment=$_POST['comment'];
    	
    $message0 = "Customer Name: " . $name . "<br/>";
    $message1 = "Company Name: " . $cname . "<br/>";
    $message2 = "Company Address: " . $add . "<br/>";
    $message3 = "E-mail Address: " . $email . "<br/>";
    $message4 = "Telephone Number: " . $tel . "<br/>";
    $message5 = "Product Type: " . $product . "<br/>";
    $message6 = "Description: " . $mess . "<br/>";
    $message7 = "Product Quantity: " . $qty . "<br/>";
    $message8 = "Additional Comment: " . $comment . "<br/>";
    	
    $message=$message0 . $message1 . $message2 . $message3 . $message4 . $message5 . $message6 . $message7 . $message8;
    
    if (empty($name)===true || empty($email) || empty($mess)===true || empty($cname)===true  || empty($add)===true || empty($tel)===true || empty($product)===true) {
    		$errors[] = 'The Fields starred with red "*" are Required!';
    	}	else {
    			if (filter_var($email, FILTER_VALIDATE_EMAIL) === false ) {
    			$errors[] = 'Please type in a valid Email-address';
    		}
    if (empty($errors) === true) { 
    mail('info@multistreamoil.com', 'Subject', $message, 'From: ' . $email);
    header('Location: successful.php?sent');
    	exit();
    		}
    	}
    
    }
    ?>
    Thank you.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    The reason is because you didn't set the header to define the e-mail as an html e-mail.

    Comment

    • Easytime
      New Member
      • Nov 2012
      • 26

      #3
      Ok...Thank you! But, sincerely, I do not know how to set the headers...pleas e can you help me? Thank you!

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Here is PHP's documentation of the mail function.
        http://php.net/manual/en/function.mail.php.

        Comment

        • Easytime
          New Member
          • Nov 2012
          • 26

          #5
          ok! Thank you! Let me go through it. I will get back to u.

          Thanks.

          Comment

          • solutionwand
            New Member
            • Dec 2012
            • 16

            #6
            Hi,
            Please check the following link for mail function documentation.


            Everything is described with simple to advanced examples.

            Comment

            Working...