Jump to content

How to get linebreaks from a form?


cs.punk

Recommended Posts

Copying something from a form and putting it into a MySQL cell, data will be removed of any line breaks... so how will i go about to make em last?.. use javascript?...

 

 

i want something

 

 

like this

 

 

see?...

 

sorry but our net is down so im using my mobile.... if you notice its a bit 'ugly' lol

Link to comment
Share on other sites

You can use preg_replace to escape the newline characters or replace them with HTML tags (<p> or <br>).  Just keep in mind that different OSes represent newlines different ways, so the user's OS will affect how the linebreaks are encoded.  (If I remember correctly, it's \n in Linux/Unix, \r in OSX and \n\r in Windows.)  So you might want to replace all occurrences of \n\r with \n, and then replace all occurrences of \r with \n, and then replace the \n with \\n or <br> or whatever.

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.