Jump to content

when submit form, textarea loses its contents


eagleweb

Recommended Posts

I am having an issue that just started, apparently since we upgraded from PHP4.2 to PHP5.0.

I have a db table field named 'content' and a form textarea named the same. The textarea shows what is presently in the database field until you click submit. If there is an error, it show the form and the POSTed info.

<textarea name="content" cols="75" rows="20" id="content"><?php if ($_POST) {$content = stripslashes($_POST['content']);} else {$content = $row['content'];} echo $content; ?></textarea>

 

I have an error statement like this:

<?php if (!empty($_POST)) {

if ($_POST['content'] == "") {$error = true; $errmsg = "Content can not be empty";} // end if content

} // end if post ?>

 

Every time I submit this form, I now get the error message telling me that Content can not be empty. I tried it with only a little bit of text, and it works fine. However, it will not work with the content that is presently in the database.

 

The db field is set as LONGTEXT.

 

There has to be something in the content that PHP5.0 does not like and that PHP4.2 did not care about. I can bring up the latest content and submit it, and I get the error message.

 

Any ideas?

 

Thanks,

EagleWeb

Link to comment
Share on other sites

The problem is not in the error checking nor in the stripslashes.

I removed both and even attempted to echo the $_POST['content'] and it echos nothing at all. Somehow, the field is going completely blank.

 

I removed everything from the field except the first 2 paragraphs and it inserted those just fine, even with the error checking and stripslashes. There is apparently something in there that PHP5.0 does not like. Last time the form was submitted, it was with PHP4.2 and it submitted perfectly. Now, with the same exact content, it won't submit without the error.

Link to comment
Share on other sites

Just thought I'd repost his code in php tags so its easier to read. :)

 

<textarea name="content" cols="75" rows="20" id="content">
<?php 
if ($_POST) {$content = stripslashes($_POST['content']);} else {$content = $row['content'];} echo $content; 
?>
</textarea>

I have an error statement like this:

<?php if (!empty($_POST)) {
if ($_POST['content'] == "") {$error = true; $errmsg = "Content can not be empty";} // end if content
} // end if post ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.