0

When im using text area the output format is different from input format eg:

input as :

hi,

hello world.

it outputs :

hi,hello world

what changes i want to make this code to get a format as input.

<html>
<head>
</head>
<body>
<form method="get" action="textarea.php">
<pre>
<textarea name="name"> </textarea>
</pre>
<input type="submit" name="submit">
</form>
<?php
if(isset($_GET['submit']))
{
    $name=$_GET['name'];
    echo $name; 
}
?>
</body>
</html>
najmal
  • 85
  • 1
  • 1
  • 9

1 Answers1

0

It looks like you need nl2br in your PHP.

if(isset($_GET['submit']))
{
    $name=$_GET['name'];
    echo nl2br($name); 
}

Also, as Quentin mentioned, you really should not be echoing user input back onto a form because that is ripe for XSS disaster, so I hope this is just an exercise for you.

merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • hm im a rookie on php i dont know there is kind of issues in php i try to learn & i try to level it right.. – najmal Jun 19 '14 at 08:38