#!/usr/bin/perl

print "Content-type:text/plain\n\n";

#available.plx

use warnings;

use strict;

use DBI;

 $ENV{"DBI_DRIVER"} = "mysql";

 $ENV{"DBI_DSN"} = "pepperdb";
print "Enter user\n";
my $user = <STDIN> ;
chomp($user);
print "Enter password\n";
use Term::ReadKey;
ReadMode('noecho');
my $pswd = ReadLine(0);
chomp($pswd);
ReadMode ('normal');
 $ENV{"DBI_USER"} = $user;

  $ENV{"DBI_PASS"} = $pswd;
my ($dbh, $sth, $name, $id);
#$dbh=DBI->connect('dbi:mysql:pepperdb','pepper',$pswd) ||
$dbh=DBI->connect() ||

die "Error opening database: $DBI::errstr\n";

$sth=$dbh->prepare("SELECT * from tutorials_tbl;") ||

die "Prepare failed: $DBI::errstr\n";

$sth->execute() ||

die "Couldn't execute query: $DBI::errstr\n";

while (( $id, $name) = $sth ->fetchrow_array) {

print "$name has ID $id\n";

}
$sth->finish();

$dbh->disconnect || die "Failed to disconnect\n";


