search
EOMAIN
}
sub handle_lastname
{ # Tweak this as you like
my ($sql_handle) = @_; # We don't actually use this here, presently.
my $query = want_specific();
if(defined($query) )
{
do_specific_lastname_query($query);
return;
}
print "
Read-Only lastname Query
\n";
print <
\n};
EFORM
}
sub do_specific_lastname_query
{
my ($lastname) = @_;
my $dbh = do_connect_ro();
my $qhdl = $dbh->prepare('SELECT * from kids where lastname = ', $dbh->quote($lastname) . ';');
$qhdl->execute();
if($qhdl->err() )
{
print "Query failed!\n";
do_close($dbh);
return;
}
my $results = $qhdl->fetchall_arrayref();
if(! defined($results))
{
print "Query failed!\n";
do_close($dbh);
return;
}
print qq{
\n};
#if(@$results = 0)
# { print "No entries matched your query\n"; }
foreach $row (@$results)
{
print qq{
};
print (map {"
$_
\n";} (@$row ) );
print qq{
\n};
}
print qq{
};
do_close($dbh);
}
sub want_specific
{
my $cq = new CGI;
my $mode = $cq->param('specific');
return $mode;
}
sub handle_entry
{ # Either present the prompt, or catch the actual request and rename, and
# tell the user that it's done.
my ($dbh, $gid) = @_;
my $cq = new CGI;
my $targ = want_specific();
if(defined($targ))
{ # User gave us info. Do it, and tell user all's good
print "Adding $targ. \n";
my $rgroup = $dbh->prepare("insert into kids(firstname,lastname,ssn) values (" . $cq->param('firstname') . "," . $cq->param('lastname') . ',', $cq->param('ssn') . ");");
$rgroup->execute;
my $checkup = $dbh->prepare("select childid from kids where ssn=$ssn;");
$checkup->execute();
$cresults = $checkup->fetchall_arrayref();
print "The childid of this child is " . $$cresults[0][0] . " \n";
print qq{Click here to continue};
}
else # Prompt the user for info
{
print "Please enter the following information.\n";
print qq{ \n};
print qq{\n};
}
}