<?
include('config.php');
if(isset($_GET['id'])){
$sid = htmlentities(strip_tags($_GET['id']), ENT_QUOTES);
$query = mysql_query("SELECT url FROM urls WHERE `short`='".$sid."'");
if(mysql_num_rows($query) > 0){
$fetch = mysql_fetch_array($query);
mysql_query("UPDATE urls SET `hits`=`hits`+'1' WHERE `short`='".$sid."'");
header("Location: ".$fetch['url']);
}else{
header("Location: ".$domain);
}
}else{
echo "No id present.";
}
?>