Hartley Posted December 11, 2006 Share Posted December 11, 2006 I have a form that runs through a validation then enters a MYSQL database. To get the syntax right, I had to do a couple PHP functions to make sure it would parse correctly visually and, in the event of any funny characters, ensure it doesn't crash the function.[code]$anythingelse = stripslashes(strip_tags($_POST['anythingelse']));$anythingelse = nl2br($anythingelse);[/code]The anythingelse is a textbox that I'm setting as a variable for later. The nl2br is to make sure the line breaks are properly registered for the visual part. Later on, I have a hidden form to submit, and it will then go to be processed:[code]$anythingelse = htmlspecialchars($_POST['anythingelse']);[/code]This was to get rid of any problems putting it into the database. However, if anyone put a line break into the function, I would get something like this:<br /><br />I see that it parsed a first <br /> into special characters, but a second line break sort of appeared out of nowhere, and I can't figure out how. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/30198-php-form-error/ Share on other sites More sharing options...
btherl Posted December 11, 2006 Share Posted December 11, 2006 To avoid this problem, only use nl2br() when you are displaying the data. Keep another copy of the data before nl2br(), and put that copy into the database.You may have to have 2 form variables, one displayed and one hidden. Link to comment https://forums.phpfreaks.com/topic/30198-php-form-error/#findComment-138827 Share on other sites More sharing options...
Hartley Posted December 11, 2006 Author Share Posted December 11, 2006 Ahh, that seemed to do the trick. I tested and it seemed to work fine: I'll let it go public for a bit and see if anything turns up. Thanks again! Link to comment https://forums.phpfreaks.com/topic/30198-php-form-error/#findComment-138833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.