I am trying to get my output out as submitted but it is not working. Say, if I submit a two paragraphed post (by pressing enter key to separate them) it doesn't output that way. It removes the paragraph and display the post as one paragraph.
Displayed Result:
I am trying to get my output out as submitted but it is not working. Say, if I submit a two paragraphed post (by pressing enter key to separate them) it doesn't output that way. It removes the paragraph and display the post as one paragraph.
Expected Result:
I am trying to get my output out as submitted but it is not working. Say, if I submit a two paragraphed post (by pressing enter key to separate them) it doesn't output that way.
It removes the paragraph and display the post as one paragraph.
HTML code:
<form method="post" role = "form" class="form-horizontal" name="" action ="<?php echo htmlentities($_SERVER['PHP_SELF']);?>">
<label for = "status" style = "font-style: italic; margin-bottom: 0;">Post something </label>
<textarea id = 'posttext' rows = '3' maxlength="320" name="postupdate" placeholder="Share ..."></textarea>
<button class="btn btn-xs btn-primary onespacedown" name = "update" type="submit">Post</button>
</form>
Thank you in advance...
The db is storing or
depending on the OS
Easy solution. Wrap the output with nl2br()
browsers expect HTML
You are looking for the nl2br() function. Wrap your variable in that to get the desired output.
nl2br($_POST['posttext']);