#!/usr/bin/perl

use DBI;
use CGI;
my $q = new CGI;
my $name = $q->param("name");
 
print "Content-type: text/plain \n\n";

$dbh = DBI->connect('DBI:mysql:inject;host=localhost:3306','inject','inject')
  or die("Connect failed. $DBI::errstr");
$query = "SELECT * FROM customers WHERE username LIKE '$name'";
print $query."\n";

$dbq = $dbh->prepare($query)
  or die("Prepare failed. ".$dbh->err.":".$dbh->errstr);
$dbq->execute()
  or die("Execute failed. ".$dbh->err.":".$dbh->errstr);

while ($hash = $dbq->fetchrow_hashref() )
  {
    foreach my $key (keys %$hash)
      {
        print $key." = ".$hash->{$key}."\n";
      }
    print "---\n";
  }

$dbq->finish();
$dbh->disconnect; 