I am making a form in html
and there is a <textarea>
tag in that form.
first.php is like:
<form method="post" action="next.php">
<textarea name="desc" raws="4">Here, Its Text Area</textarea>
<button type="submit" name="submit">NEXT BUTTON</button>
</form>
And next.php is like:
<?php
if(isset($_POST["submit"]))
{
$desc = $_POST["desc"];
echo $desc; //<------ ECHO LINE 1
}
else
{
header("location: first.php");
}
And when I am typing this message:
Hi,
Helo there,
I am LakshyaK2011.
And echoing in it next.php, in echo line 1 (See In next.php's code)
It is displaying like this:
Hi, Helo there, I am LakshyaK2011.
is there any fixes to it? Thanks,
I have tried:
(I didn't know what to do so I tried nothing)
I have expected:
I will enter:
Hi,
Helo there,
I am LakshyaK2011.
And it will print same as that.
Not like:
Hi, Helo there, I am LakshyaK2011.
CodePudding user response:
To display new line in HTML format, you need something such as <br>
So Change
echo $desc;
to
echo str_replace(chr(13), '<br>',$desc);