eagleweb Posted August 18, 2009 Share Posted August 18, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/170757-when-submit-form-textarea-loses-its-contents/ Share on other sites More sharing options...
Cosizzle Posted August 18, 2009 Share Posted August 18, 2009 try this... <?php if (empty($_POST['content'])) { $errmsg = "Content can not be empty"; } // end if content else { // put info in DB } ?> Quote Link to comment https://forums.phpfreaks.com/topic/170757-when-submit-form-textarea-loses-its-contents/#findComment-900551 Share on other sites More sharing options...
gergy008 Posted August 18, 2009 Share Posted August 18, 2009 I think you might have to not look for if its not empty. <?php if (empty($_POST)) { if ($_POST['content'] == "") {$error = true; $errmsg = "Content can not be empty";} // end if content } // end if post ?> Quote Link to comment https://forums.phpfreaks.com/topic/170757-when-submit-form-textarea-loses-its-contents/#findComment-900554 Share on other sites More sharing options...
.josh Posted August 18, 2009 Share Posted August 18, 2009 ditch the stripslashes. Quote Link to comment https://forums.phpfreaks.com/topic/170757-when-submit-form-textarea-loses-its-contents/#findComment-900556 Share on other sites More sharing options...
eagleweb Posted August 18, 2009 Author Share Posted August 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/170757-when-submit-form-textarea-loses-its-contents/#findComment-900953 Share on other sites More sharing options...
deansatch Posted August 18, 2009 Share Posted August 18, 2009 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/170757-when-submit-form-textarea-loses-its-contents/#findComment-900958 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.