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