Forum Moderators: coopster

Message Too Old, No Replies

textarea values

         

Fenrir

12:14 am on Feb 6, 2007 (gmt 0)

10+ Year Member



Hi, I'm just learning PHP so I'm afraid this is almost certainly a pretty basic question.

I can't seem to pick up the value from a textarea what am I missing?

The textarea code looks like this:

<textarea rows="20" cols="90" name="entry"></textarea>

and to pick it up I am using this:

echo "Entry = " . $_REQUEST["entry"] . "<br>";

I've tried to use $_POST but that doesn't work either. There's no problem with picking up the other fields so the form basically works but not the textarea.

Thanks in advance for any help.
--
Jan

eelixduppy

12:22 am on Feb 6, 2007 (gmt 0)



Welcome to WebmasterWorld, Jan!

Your syntax is "technically" correct, however it should look something like this:


echo "Entry = ".$_POST["entry"]."<br>";
#
#or, if you are running a PHP version < 4.1.0, use the following
#
echo "Entry = ".$HTTP_POST_VARS["entry"]."<br>";

Other than that, you should be good. Oh, and one more thing. Make sure you have something either typed into the textarea or between the tags of the textarea as if you don't, the $_POST variable will have nothing in it, and appear to be empty.

Good luck! :)

cameraman

12:43 am on Feb 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



and make sure your form tag is using POST as its method
<form method="post"

whoisgregg

2:23 pm on Feb 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And to debug form values generally, putting this at the head of your script is handy:

echo '<pre>'; print_r($_POST); print_r($_GET); echo '</pre>';

If you keep it on one line it's easy to turn it off just by commenting the line:

//echo '<pre>'; print_r($_POST); print_r($_GET); echo '</pre>';

Fenrir

5:19 pm on Feb 6, 2007 (gmt 0)

10+ Year Member



Thank you very much for your responses eelixduppy, cameraman and whoisgregg. I'm glad to say that it is working today but I have no idea why it wasn't previously.

eelixduppy's response gave me the idea of trying to hardcode some text in between the tags to see if I got a response that way which I did, so I tried that and adding text into the text box and that worked, took the hard coding out and it carried on working. I do hate it when that happens, I don't mind problems so much if I can feel I've fixed them (albeit with help), it's unsettling when they fix themselves.

Thanks for the code snippet whoisgregg, I have a feeling I will be using it a lot.