script not working correctly
- From: "onlineviewer" <lancerset@xxxxxxxxx>
- Date: 7 Nov 2006 19:45:53 -0800
Hello All
I am trying to get this script, to work although i'm sure something is
missing, not sure what though. I see that whatever you search for,
executes the query, so i'm not sure how to take the query from the html
form and pass it properly into my .cgi script. This is my searchdb.cgi
script. Thank you,,.
#!/usr/bin/perl
use CGI;
use DBI;
$db="mydb01";
$host="localhost";
$user="username";
$password="password";
$query = new CGI;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
print "<html><head><title>MYSQL Search";
print "</title></head><body><h1>";
print "MYSQL Search</h1><p>";
my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host",
$user,
$password)
or die "Can't connect to database:
$DBI::errstr\n";
$sth = $dbh->prepare("select user_login from people")
or die("Couldn't prepare");
$sth->execute;
while (@row = $sth->fetchrow_array){
print "id: $row[0], name: $row[1]\n";
print "\n";
}
print "</body></html>\n";
$dbh->disconnect;
################################################
searchdb.html
<html>
<head>
<title>
Database Access
</title>
</head>
<body>
<h1>
Database Access
</h1>
<p>
<form action="cgi-bin/searchdb.cgi" method=post>
<br>
search:
<input type=text name=place>
<br>
<input type=submit value="Search database">
</form>
</body>
</html>
.
- Prev by Date: Re: fetch or fetch hash/array ref?
- Next by Date: Re: Best authentication methods for CGI <- PERL -> DBI
- Previous by thread: DBD::ADO and Access IMAGE (OLE Object) fields...
- Next by thread: Re: Best authentication methods for CGI <- PERL -> DBI
- Index(es):
Relevant Pages
|
|