Good afternoon dear developers,
upon gnoming through the OpenGuide to London and inserting pages with
horribly long Website Addresses a though came cross my mind. I wrote a CGI
that reads an URL from a MYSQL defined by a 5-character code, and sends a
Location: Command to the Browser. It will be needed to write some CGIs that
make it possible to add a link between the 5-char-code and an url to the
database. There are some more possiblities to get rid of long urls. I would
be happy if some developer would act upon my request.
This is my CGI:
#!/usr/bin/perl
use DBI;
$DB_DB = "test";
$DB_Host = "localhost";
$DB_User = "root";
$DB_Password = "***";
$dbh = DBI->connect("dbi:mysql:$DB_DB:$DB_Host",$DB_User,$DB_Password);
$sth = $dbh->prepare("select url from test where shortname =
'".$ARGV[0]."'");
$sth->execute;
if($sth->rows == 0)
{
print "Error";
} else {
while ($row = $sth->fetchrow_hashref)
{
print "Location: ",$row->{'url'},"\n\n";
}
}
$dbh->disconnect;
exit 0;
The DB looks temporalily like this
test
|--- test
|--- ID, shortname, url
Regards
Kai M Poppe