Forum Moderators: coopster

Message Too Old, No Replies

a href links in php

         

xentsear

7:50 am on Jul 9, 2003 (gmt 0)

10+ Year Member



Hmm... i had this textarea...and whenever the tags comes in the textarea :

<a href="www.somesite.com">Some Site</a>

and uploaded to the database, when the data is retrieve, it will lead to :

[mydomain.com...]

Is there anyway to verify the input of the user, and add http:// if necessary?

Robber

8:24 am on Jul 9, 2003 (gmt 0)

10+ Year Member



Hi xentsear,

Welcome to WebmasterWorld. You coule use a regular expression to chec the string has http;// in it, if not add it.

Or you could use something like strpos(), if it returns false then you must add the [....]

Cheers

xentsear

11:47 am on Jul 9, 2003 (gmt 0)

10+ Year Member



Hmm..im a little new to php/mysql. Could be please show me a sample of the code?

Robber

1:08 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



You could try something like:

if(strpos($link,'http://') === false){
$link = 'http://' . $link
}

Hope that helps