I am using php and html codes in the same file for a contact form.
When I write multiple lines in a html form (textarea):
(name="TBody" cols="100" rows="10" class="largertextarea" required="required" placeholder="Leave A Message Here"),
the php received the information and put all of them in the same line :
$body = $_POST["TBody"];
$msgbody = "- Message is about:" . "<br>" . $body;
For example :
Hi,
Hope all are fine.
Bye.
What I receive in email is like this :
Hi, Hope all are fine. Bye.
So, how can I put them in multiple lines?
When you catch your $_Post['textarename']
Use $message=nl2br($_POST["TBody"];);
Then that will save your <br>
tags from textarea
Here's a short example that could give you the basic idea of how it's done:
If(isset($_POST['submit']){
$msg= nl2br($_POST['text']);
}
Now line breaks are added where they should be, if you're displaying this on html however you don't have to use the nl2br function, but use the CSS property:
div{
white-space: pre-wrap;
}