<form><textarea><?echo is not working!

Hi everyone,
All that is contained in my “form” code is a “textarea” input and a submit button.
All I want is that assigned to that “textarea” to show up. This is the php code:

<?php
if(isset($_POST['send']) && !empty($_POST['send']))
{
	$user_input=$_POST['user_input'];
}
else
{
	$user_input='';
}
?>
<form action="test.php" methos="post">
	<textarea name="user_input" cols="30" rows="6"><?php echo $user_input; ?></textarea>
	<input type="submit" value="Send it" name="send">
</form>

Could anyone please pinpoint why I do not see my input at the textarea after i add text to it?
Thanks

You spelt the method attribute wrong in your form tag, making the HTTP method for your form default to using GET (hence why you should see the data you’re sending within your URI (the query string)).

EDIT: Also be aware that you’re vulnerable to XSS attacks. You need to ensure that the user data you’re outputting has been properly escaped (using either htmlentities() or htmlspecialchars()).

1 Like

Is this line correct?

if(isset($_POST['send']) && !empty($_POST['send']))

or should it read

if(isset($_POST['send']) && !empty($_POST['user_input']))

That won’t be the problem btw, just another thing that looks wrong.

1 Like

Very sorry to have mixed up my code !!!
You are right: A bit more concentration would save more confusion :frowning:Sorry

Thanks !
It works both ways only I wrote “methos” instead of “method”.
blush:
Really sorry !

If I tell you the amount of times that I have done the same…

1 Like

:smile:Some consolation…

1 Like