Home > Archive > PHP Language > May 2006 > inserting data via browser(textarea) into database
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
inserting data via browser(textarea) into database
|
|
| Tommy DN 2006-05-29, 6:58 pm |
| 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.
| |
| frizzle 2006-05-29, 6:58 pm |
|
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.
| |
| J.O. Aho 2006-05-29, 6:58 pm |
| 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.ph...=regexp&lang=en
//Aho
| |
| Brian Mansell 2006-05-29, 9:57 pm |
| This should be able to handle converting urls to links...
function text_to_link_conversion($text) {
$text =
eregi_replace('([[:space:]()[{}])(w
ww.[-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;
}
|
|
|
|
|