Links submitted through forms...
Posted: Sun Feb 06, 2005 7:34 pm
I have this code:
Here's the problem:
When I type in a link before I put in any text I get a link that says http:// but the rest of the link isn't there. If I type in text before I put a link it won't catch the link at all, and it just shows up as regular text.
Also, it only catches links that start with http://, https://, and ftp://. It won't catch links that start with www (as most people would input when submitting a link).
Any help?
(PS, in lamons terms I'm trying to automatically turn links into hyperlinks when submitted through a form)
feyd | please use the formatting tags we provide
Code: Select all
$smilies = array(too many smilies to post in this message);
$smiliesimg = array(too many images to post);
$message2 = str_replace($smilies, $smiliesimg, $message);
$message3 = mysql_real_escape_string(nl2br(strip_tags($message 2, '<img><a>')));
$pattern = "^(http|https|ftp)\://їa-zA-Z0-9\-\.]+\.їa-zA-Z]{2,3}(:їa-zA-Z0-9]*)?/?(їa-zA-Z0-9\-\._\?\,''/\\\+&%\$#\=~])*ї^\.\,\)\(\s]$";
$replacement = "<a href="\\1">\\1</a>";
$message4 = eregi_replace($pattern, $replacement, $message3);
$sql = "INSERT INTO privatemessages (message, whosent, whoreceived, date, time, previousmessage) VALUES ('$message4', '".$_COOKIEї'username']."', '$musername', '$date', '$time', '$previousmessage')";
$query = mysql_query($sql) or die(mysql_error());When I type in a link before I put in any text I get a link that says http:// but the rest of the link isn't there. If I type in text before I put a link it won't catch the link at all, and it just shows up as regular text.
Also, it only catches links that start with http://, https://, and ftp://. It won't catch links that start with www (as most people would input when submitting a link).
Any help?
(PS, in lamons terms I'm trying to automatically turn links into hyperlinks when submitted through a form)
feyd | please use the formatting tags we provide