i want to create short url service website. (4url dot net)
currently unindexed IDs redirect to the main page except if the ID contains numbers only then its redirect to blank page.
the PHP code is(this is independent file which receive the ID from typed url):
Code: Select all
<?
ob_start();
include("config.php");
if(isset($_GET['id'])) {
$gid = mysql_real_escape_string($_GET['id']);
$qs = mysql_query("SELECT url FROM $table WHERE tag = '$gid';") or die('MySQL error: '.mysql_error());
if (mysql_num_rows($qs) == 0) {
$qs = mysql_query("SELECT url FROM $table WHERE `id` = $gid;") or die(header("Location: /"));
mysql_query("UPDATE url SET count=(count + 1) WHERE `id` = $gid;") or die('MySQL error: '.mysql_error());
} else
mysql_query("UPDATE url SET count=(count + 1) WHERE `tag` = '$gid';") or die('MySQL error: '.mysql_error());
while($data = mysql_fetch_array($qs)) {
if ($frame == 1) {
include("frame.php");
echo "<iframe name=\"pagetext\" height=\"100%\" frameborder=\"no\" width=\"100%\" src=\"$data[0]\"></iframe>";
} else if ($frame == 0) {
if ( !preg_match( "/^http/", $data[0] ) ) {
header("Location: http://$data[0]");
} else {
echo header("Location: $data[0]");
}
}
}
}
ob_flush();
?>Thanks
Kobi