?
Solved

Form Posting TextArea (No Text)

Posted on 2011-09-05
9
Medium Priority
?
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 84

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
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
LVL 84

Expert Comment

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

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

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

752 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