473,480 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Error in trying to pass large amount of data in textarea?

Hi:
I'm trying to pass HTML codes via a form through textarea. It seems
that if I put in text larger than certain size, the data I receive
through the POST array becomes [first part of data]var_name = [data].
Is this a common problem in php? I'm currently using PHP 4.3.9
Here's the code:

<?=$test?> <!--data already distorted -->
<form action="<?=$_SELF?>" method="POST">
<textarea name="test"><?=$test?></textarea>
<input type="submit" name="update">
</form>
Jul 17 '05 #1
4 5223

Justin:

In the example code you have given, your posted data (ie the contents
your variable $test) need to be escaped before being displayed or
re-inserted into the form - otherwise the HTML of the form is mixed up
with the HTML of your posted data.

Try something along these lines:

<?php
print htmlspecialchars( stripslashes( $_POST[ 'test' ] ) );
?>
<hr />
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<textarea cols="50" rows="10" name="test">
<?php
print htmlspecialchars( stripslashes( $_POST[ 'test' ] ) );
?>
</textarea>
<br />
<input type="submit" name="update">
</form>
(nb I added stripslashes() in case you have magic_quotes enabled)
---
Steve

Jul 17 '05 #2
.oO(Steve)
(nb I added stripslashes() in case you have magic_quotes enabled)


Before using stripslashes() you have to check the setting of magic
quotes with get_magic_quotes_gpc() to avoid errors. If MQ are off and
the text contains literal slashes your code will lead to broken data.
Don't rely on a specifc server configuration if you don't have control
over it (the same goes for short_open_tags and register_globals).

Micha
Jul 17 '05 #3

Micha:

All correct. I hesitated before including stripslashes() and I agree I
should really have added test code around it - but I ended up leaving
it in anyway after noting that the style of the OP's sample code was
from an earlier PHP epoch when MQ were likely to be on by default.
---
Steve

Jul 17 '05 #4
Justin Tang wrote:
I'm trying to pass HTML codes via a form through textarea. It seems
that if I put in text larger than certain size, the data I receive
through the POST array becomes [first part of data]var_name = [data].
Is this a common problem in php? I'm currently using PHP 4.3.9


Try adding enctype="multipart/form-data" to the <form> tag, as suggested
in comments to this bug: http://bugs.php.net/bug.php?id=22427 This may
or may not help.

(Also, you should escape output with htmlspecialchars(), and may need to
use stripslashes() if magic_quotes_gpc is active. But that's a general
issue...)

-- brin vibber (brion @ pobox.com)
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2776
by: amerar | last post by:
Hi All, I'm trying to track down this error. I had a web site written for my company. There is an admin function where we can select photos to be uploaded to the server for display on the...
7
2552
by: Spacen Jasset | last post by:
The main two desirable things I feel error handling should provide are these: 1) Debugging and diagnostic aid 2) User feedback One method that is used a fair amount it to 'say' that all...
12
6161
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses...
4
8919
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The...
0
1438
by: =?Utf-8?B?TG93bGFuZGVy?= | last post by:
Hello, I've built a web application that uses client script callbacks. It is used on a large network with a large variety of user OSes and IE versions. It was tested on IE 6 on different setups...
0
2164
by: jianxin9 | last post by:
Hi everyone, I don't have a lot of experience with ASP and I was hoping someone could help me. I want to use our ASP form along with some javascript code to create a form where our patrons can...
3
1741
by: mirianCalin | last post by:
the code saves the category, image title, image, and feature.. but the problem is that the "feature" is not saved, but the others were saved.. this is the data types of my table category = text...
2
1704
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Have a complex process where I need to Import a large amount of data then run some transformations on this data then import into DataBase. The transformation involves multiple fields and multiple...
0
2346
by: jcatubay | last post by:
I have a function that returns a list more than 200000 objects and the object has 37 fields. I added the wcf as a web reference so i dont have to add any configuration item in my web apps config...
0
6903
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5318
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4468
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2987
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.