468,247 Members | 1,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

inserting data via browser(textarea) into database

I just wanted to make something that creates html-code which should be
inserted in a mysql database.

The user should type text in a textarea. When the user submits the data,
all enters should be translated into "<br>" and it would be nice if the
user could also insert links ( "<a href="..." ) in the formular.

Does someone knows a good, very simple script? There are wysiwyg editors
on the net, but I don't need to modify fonts, colors et cetera. The most
important thing are the "<br>" tags which should be generated.
May 29 '06 #1
3 4586

Tommy DN wrote:
I just wanted to make something that creates html-code which should be
inserted in a mysql database.

The user should type text in a textarea. When the user submits the data,
all enters should be translated into "<br>" and it would be nice if the
user could also insert links ( "<a href="..." ) in the formular.

Does someone knows a good, very simple script? There are wysiwyg editors
on the net, but I don't need to modify fonts, colors et cetera. The most
important thing are the "<br>" tags which should be generated.


Concerning the breaks, you'd might wanna check out the built in php
function nl2br()
Found at http://php.net/nl2br
Turns (textfield) breaks into <br />.

Frizzle.

May 29 '06 #2
Tommy DN wrote:
I just wanted to make something that creates html-code which should be
inserted in a mysql database.

The user should type text in a textarea. When the user submits the data,
all enters should be translated into "<br>" and it would be nice if the
user could also insert links ( "<a href="..." ) in the formular.


new line to <br> is easily done with nl2br()
http://www.php.net/manual/en/function.nl2br.php

For urls you will most likely need to make your own function that uses regexp,
there are a number of functions you can use to transform a web-address into a
anchor.
http://www.php.net/manual-lookup.php...regexp&lang=en

//Aho
May 29 '06 #3
This should be able to handle converting urls to links...

function text_to_link_conversion($text) {
$text =
eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2">\\2</a>', $text);
$text =
eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $text);
return $text;
}

May 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Gadrin77 | last post: by
5 posts views Thread by joelbyrd | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.