• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

TextArea

Hi,

I have a simple
<TEXTAREA NAME="comment" ROWS=6 COLS=40></TEXTAREA> within a form..
I would like to do is basically have any text typed into the text area echoed to the next page once the submit button is clicked...
I have no idea on how to do this..

Any help would be greatful..
0
Eaddy Barnes
Asked:
Eaddy Barnes
1 Solution
 
TomeeboyCommented:
In the code for the page that form is being submitted to, use:

echo $_POST['comment'];
0
 
RoonaanCommented:
You can use this:

if($_SERVER['REQUEST_METHOD'] == 'POST') {
  echo 'Comment: ';
  echo htmlspecialchars($_POST['comment']);
}

-r-
0
 
Brian BushSolutions ArchitectCommented:
echo $_REQUEST["comment"];

There you go 3 answers.
Tomeeboy assumes you used the post method to submit your form.
Roonaan, assumes that too, but checks first.

If you use $_REQUEST it will get a POST or GET form variable.
--brian
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RoonaanCommented:
$_REQUEST will actually also get $_COOKIE variables, brian ;-)

-r-
0
 
TomeeboyCommented:
Better to do it right to begin with, rather than compensate for the wrong method :)
0
 
BogoJokerCommented:
I seriously, seriously doubt somebody would put textarea contents into $_GET.
Setting a Cookie is just as unlikely.
$_POST is the only Logical one.

But $_REQUEST should work for any case, unless it is being rewritten somewhere.
0
 
guilhermeblancoCommented:
Everybody here answers the question... I'll just complement all of them.

Use lowercase HTML tags... and prefer to stylish things, not delivering to HTML this job.

You simple HTML code should be something like:

<textarea name="comment" style="width: 200px; height: 100px;"></textarea>


Even if you are building a simple script, you must have security in your mind. Imagine how many headaches will you have if you do not bother too much with security... even if you are a new programmer in the language, try to learn security techniques.
I think a good one to apply in your script is to htmlentities the user comment. Htmlentities is a function that converts any found chars that has another notation in HTML entity to its one. Good... but it supports a second argument that converts quotes, and I highly suggest you to use it.

so, the right way to output the send code is this:

if ($_SERVER['REQUEST_METHOD'] == 'POST')
    echo htmlentities($_POST['comment'], ENT_QUOTES);


Just put this sentence in your mind and try to follow it everytime: "Filter input, Escape output!"


I hope this helps...

Regards,
0
 
Eaddy BarnesITAuthor Commented:
Thanks guys..



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now