#!/usr/bin/perl -w use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI::Pretty; use CGI qw(:standard :cgi-lib -debug fatalsToBrowser); use DBD::mysql; use DBI; my $cgi = new CGI; my ($dbh, $selectstr, $sth, @row, $uid, $psw); my ($numrecs, $numrows, $select_str); my $CoordCookie = cookie(-name=>'MGH_Coord',-value=>0,-path=>'/',-domain=>'.rbhyland.org'); print $cgi->header(-cookie=>$CoordCookie,-Cache_Control=>'no-cache'); print start_html(-title =>'HortLine Database Sign In', -style =>'http://www.HortLine.rbhyland.org/Styles.css', -script=>{-language=>'JAVASCRIPT', -src=>'http://www.HortLine.rbhyland.org/Scripts.js'}); print "
", "

MG logo", " Penn State Consumer

 Horticultural Help Line


"; if (!param('uid')) { print start_form(-method=>"POST",-action=>"http://hortline.rbhyland.org/Login.cgi"), "
", p,"User ID   ",textfield(-name=>'uid',-id=>'uid',-value=>'',-size=>20,-maxlength=>50), p,"Password ",password_field(-name=>'psw', -id=>'psw', -value=>'', -size=>20, -maxlength=>50), p,submit(-name=>'submit', -value=>'Login'), "
", end_form ; } else { $uid=param('uid'); $psw=param('psw'); $dbh = DBI->connect("","","", { RaiseError => 1,AutoCommit => 1 }) or &dienice("Can't connect to database: $DBI::errstr"); $selectstr = "select * from Users where Uid = ? AND Psw = ?"; $sth = $dbh->prepare($selectstr) or &dbdie; $sth->execute($uid,$psw) or &dbdie; my @UP = $sth->fetchrow_array(); if (!@UP) { &dienice(qq(User/Psw incorrect. Go to the Login page and try again.)); } else { print start_form(-method=>"post",-action=>"http://hortline.rbhyland.org/Switchboard.cgi"), hidden('userid',"$UP[0]"), hidden('county',"$UP[2]"), hidden('coord',"$UP[3]"), hidden('state',"$UP[4]"), br,br,"
", submit(-name=>'GotoSwitchboard', -value=>'Go To Main Menu'), "
", end_form; } } print end_html; sub dienice { my ($msg) = @_; print "$msg"; exit; } sub dbdie { my ($errmsg) = "$DBI::errstr
"; &dienice($errmsg); }