Hello, I am using the below code to retrieve a user submitted URL from a database if one exists and turn their username into a link.
But for some reason it is adding the url to the current pages url. As so:
“www.currentsite.com/www.targetsite.com”
I’ve had a look and the common theme seems to be that if the URL lacks “http://” then the above is what you get. Add “http://” and it works fine giving you “www.targetsite.com”.
I’m guessing that it has something to do with formatting when putting it into and retrieving it from the DB? I’ve had the problem before but I cannot remember how I fixed it so help is appreciated.
if(isset($_POST['website'])) { $url=mysql_real_escape_string($_POST['website']);} else {$url = '';}
I’ve tried this line with and without stripslashes but not gotten anywhere.
$userurl=($commentData['author_url']);
<?php
if(trim($userurl) != '')
{
echo "<a href='".$userurl."' target='_blank' rel='nofollow'>".$username."</a></b>";
}
else
{
echo $username."</b>";
}
echo $comment; ?>