I have created url shortner by using the link http://devlup.com/programming/php/create-url-shortener-php/853/ for this i am using EasyPhp5.3.6.0,,but i am not finding the required output,,that means after clicking shortened url it is not redirecting to the original page.Possibly i am thinking the issue is on database side This is the steps which i did in database side,please let me know anything wrong
First i went to Configuration->PhpMyAdmin link ,,Then i created Database named "leaf" here i didnt selected 'Collation' named dropdown i made table name as "team" with number of fields as "3" then i modified fields like shown below
**Field id url shortened**
Type INT VARCHAR VARCHAR
Lenght/Values 255 10000 10000
Default None None None
Then i made 'id' as Primary Key
These are some part of php code where database handling going one in sortner.php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("leaf", $con); //Replace with your MySQL DB Name
$urlinput=mysql_real_escape_string($_POST['url']);
$id=rand(10000,99999);
$shorturl=base_convert($id,20,36);
$sql = "insert into team values('$id','$urlinput','$shorturl')";
mysql_query($sql,$con);
echo "Shortened url is <a href=\"http://projects.devlup.com/url/". $shorturl ."\">http://devlup.com/". $shorturl ."</a>";
mysql_close($con);
?>
In decoder.php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("leaf", $con); //Replace with your MySQL DB Name
$de= mysql_real_escape_string($_GET["decode"]);
$sql = 'select * from team where shortened="$de"';
$result=mysql_query("select * from team where shortened='$de'");
while($row = mysql_fetch_array($result))
{
$res=$row['url'];
header("location:$res");
}
Kindly let me know anything is wrong here,,My all files are under root folder(www) that means C:\Program Files\EasyPHP-5.3.6.0\www\test