Jump to content

PHP <br /> Form Error


Hartley

Recommended Posts

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:

&lt;br /&gt;<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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.