Hello! π
Thanks a lot for the help, it is working now. I do understand that the code can be made more secure and compact. I do have a small question below at the end.
This is how i did it.
First file
while($row=mysql_fetch_array($Result))
{
echo " (";
echo "<a href=\"showurl.php?id=".$row['id']."\">";
echo $row['url'];
echo " (";
echo $row['clicks'];
echo ")";
echo "</a><br>\n";
} mysql_close($dbh);
Showurl.php file:
<?
$id = $_GET['id'];
$Link=mysql_connect ("localhost", "total_xmb1", "xxxxxor" die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("total_xmb1");
$Query = "UPDATE hostedurls SET clicks=clicks+1 WHERE id=$id";
mysql_query($Query) or die("Error: ".mysql_error()." in query: ".$Query);
mysql_close($Link);
$dbh=mysql_connect ("localhost", "total_xmb1", "xxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("total_xmb1");
$Query = "SELECT * FROM hostedurls WHERE id = $id" or die (mysql_error());
$Result = mysql_query($Query) or die("Error: ".mysql_error()." in query: ".$Query);
$row=mysql_fetch_array($Result);
$url = $row['url'];
header("Location: $url"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
This works just fineπ
I do actually have a follow up question, I would be happy if I could open the link in a new browser window instead. To add taget=_"blank" in one of these:
(first page)
echo "<a href=\"showurl.php?id=".$row['id']."\">";
or here(second page):
header("Location: $url");
Thanks a lot again.