Solved

Form Posting TextArea (No Text)

Posted on 2011-09-05
9
357 Views
Last Modified: 2012-05-12
Hi all,

I have a problem when posting the data of a form (field).

I have a Textarea in my form:

<label for="eh-textarea-desc">Description:</label>
<textarea cols="40" rows="8" name="eh-textarea-desc" id="eh-textarea-desc"></textarea>

Open in new window


I this post(submit) the text that I've written ...

My php collects the data ..BUT no Description .. instead I get "on" (without quotes), which is what I would expect to get from a checkbox not a textarea ... anyone got any idea why this could happen?

Thanks






0
Comment
Question by:error77
  • 4
  • 3
  • 2
9 Comments
 
LVL 24

Expert Comment

by:mankowitz
ID: 36485786
it should work as expected. Show us the rest of the form as well as the php script you are using to handle it. Two things come to mind

1. Is there another part of your form called eh-textarea-desc?
2. Is your php script overwriting your variable?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 36485832
I agree, that should work in a form.  And you have two items with the same name, I think you will only 'see' the second or last one.   I think you need to show us more code cause something isn't quite right.
0
 

Author Comment

by:error77
ID: 36485839
This is what I've done:

First I define a variable and set to empty

$ehTextareaDesc = '';

Then I assign the variable to the post

if(isset($_POST['eh-textarea-desc'])) {
             $ehTextareaDesc = $_POST['eh-textarea-desc'];
      }

Note: The above is to avoid undefined errors

Then on the form I have this:

<label for="eh-textarea-desc">Description:</label>
<textarea cols="40" rows="8" name="eh-textarea-desc" id="eh-textarea-desc"></textarea>


Then once I submit I have the php to show me what has been passed:

echo 'The Description Posted is '.@$_POST["eh-textarea-desc"];

The above is returning "on"

Hope this helps.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 36485870
Why do you have the '@' symbol?  Use:

echo 'The Description Posted is '.$_POST["eh-textarea-desc"];
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 36485875
What are you typing into the textarea before you POST it?
0
 

Author Comment

by:error77
ID: 36485905
I'm posting just any text..for example: "This is a textarea description"

0
 

Author Comment

by:error77
ID: 36485955
OK, I've been doing some more test and here are the results:

I currently navigate to the textarea field using sub lists

example:

<ul>
<li><a href="#">Go to the Textarea</a>
<ul>
<li>
<textarea></textarea>
</li>
</ul>
</li>
<ul>

So I navigate to the textarea ... type whatever .. hit the back arrow and submit.

For some reason the form is not retaining the data when I submit it although if I navigate back to it the data IS there.

Any ideas on why this might be happening?



</li>
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 36486101
try this:

first line of your script

print "<pre>";
print_r ($_POST);
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 36486149
Why would the form retain the data?  That description doesn't make any sense.

Here are a set of files I made up for another question that demonstrate posting data from one page to another including a <textarea>.

formA.html
formA1.php
formA2.php
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to dynamically set the form action using jQuery.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now