Hi all,
I am looking to understand Html entities & html special chars in more details.
I have a form and text area that users complete, the databse updates correctly and displays the information.
The problem im facing is this:
When the database displays the data, its display incorrectly.
For example:
If the user enters
Line 1
Line 2
Line 3
The data is stored correctly in the database, including the line brakes.
But when the data is displayed on the page, it is displaying as
Line 1 Line 2 Line 3 ? How can I display the data from the database correctly.
Here is my form
<form style="width:100%;" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<div><div class="p">
<textarea name="sabout" cols="35" rows="5" class="ta" id="sabout" style='width:99.9%;'/><?php echo htmlspecialchars($_POST['sabout']); ?></textarea></form>
I have the following variable to display the data from the database -
$sabout = htmlspecialchars($sabout);
Displaying the variable in my page
<?php if($sabout){echo $sabout; }?>
any help would be appreciated, thanks