Location: PHPKode > scripts > url shortener script > url-shortener-script/show.php
<?php
	if($_GET['id']){
		require("mysql.php"); // to establish a connection to the db
		$id = addslashes($_GET['id']);
		$getUrl = mysql_query("select url from urls where id = $id"); // check if the id exists in the db
		if(mysql_num_rows($getUrl)==1){ // if so we redirect using the header function
			$url = mysql_fetch_array($getUrl);
			header("location:".$url['url']); 
		} else {
			echo "Error : invalid hash";
		}
	} else {
		echo "Error : no hash";
	}
?>
Return current item: url shortener script