/    Sign up×
Community /Pin to ProfileBookmark

convert a submitted link

Hi,

Would it be possible to covert every link submitted in a form into another link?

For example, the following submitted text
==================================================

Hello! My site is

[url]http://www.site-name.com[/url]
==================================================

converted to

==================================================
Hello! My site is
<a href=”http://www.domain.com/r?i=site-name.com

“>[url]http://www.site-name.com[/url]</a>
==================================================

Another extention would be this:

Would it be possible to write every link submitted in a form to a database, and so it would go like this…

From…
==================================================

Hello! My site is

[url]http://www.site-name.com[/url]
==================================================

converted to

==================================================
Hello! My site is
<a href=”http://www.domain.com/r?i=1

“>[url]http://www.site-name.com[/url]</a>
==================================================

Thanks

Daniel

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@scragarNov 30.2004 — [code=php]
$txt = "hello follow the link below:<br>http://www.site-name.com";
$txt = str_replace("/http:///i","<a href=http://www.domain.com/r?i=",$txt);
$txt = str_replace("/.com/i",".com>www</a>",$txt);
$txt = str_replace("/.co.uk/i",".co.uk>www</a>",$txt);
$txt = str_replace("/.me.uk/i",".me.uk>www</a>",$txt);
$txt = str_replace("/.org/i",".org>www</a>",$txt);
$txt = str_replace("/.net/i",".net>www</a>",$txt);
$txt = str_replace("/.tk/i",".tk>www</a>",$txt);
$txt = str_replace("/.fr/i",".fr>www</a>",$txt);

echo($txt);
/* writes:
hello follow the link below:<br><a href=http://www.domain.com/r?i=site-name.com>www</a>
*/[/code]


this is only a rough example, but it could be modified to acept a normal link through your site if you want to wait a while...
×

Success!

Help @danlohye spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...