#!/usr/bin/perl # Copyright 2001-2007 Leslie Richardson # Update by Kevin Waddell # This file is part of Open Admin for Schools. # Open Admin for Schools is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. my %lex = ('Add Discipline Record' => 'Add Discipline Record', 'Your record is now stored in the database.' => 'Your record is now stored in the database.', 'Mistake' => 'Mistake', 'Description' => 'Description', 'Action' => 'Action', 'If Repeated' => 'If Repeated', 'Parent Contact' => 'Parent Contact', 'Author' => 'Author', 'Main' => 'Main', 'Discipline Page' => 'Discipline Page', 'Add another record' => 'Add another record', 'There was an error storing your data' => 'There was an error storing your data', 'Please contact your network adminstrator at' => 'Please contact your network adminstrator at', 'Please record the following error:' => 'Please record the following error:', 'Back to Discipline Page' => 'Back to Discipline Page' ); use DBI; use CGI; my $q = new CGI; print $q->header; my %arr = $q->Vars; require "../../etc/admin.conf" or die "Cannot read admin.conf!"; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); # quote all items. foreach my $key (keys %arr ) { if ( $arr{$key} ) { $arr{$key} = $dbh->quote( $arr{$key} ); } else { $arr{$key} = $sql{default}; } } #foreach my $key (keys %arr) { print "K:$key V:$arr{$key}
\n"; } my $sth = $dbh->prepare("insert into discipline values ( $sql{default}, $arr{date}, $arr{studnum}, $arr{mistake}, $arr{description}, $arr{action}, $arr{ifrepeat}, $arr{parent}, $arr{author}, $arr{private} )"); $sth->execute; print "$doctype\n". $lex{'Add Discipline Record'}. " $chartype\n\n"; if (not $DBI::errstr ) { print "

". $lex{'Your record is now stored in the database.'}. "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
". $lex{Mistake}. "$arr{mistake}
". $lex{Description}. "$arr{description}
". $lex{Action}. "$arr{action}
". $lex{'If Repeated'}. "$arr{ifrepeat}
". $lex{'Parent Contact'}. "$arr{parent}
". $lex{Author}. "$arr{author}
\n"; print "

[ ". $lex{Main}. " | ". $lex{'Discipline Page'} ." | ". $lex{'Add another record'}. " ]

\n"; } else { print "

". $lex{'There was an error storing your data'}. "
\n"; print $lex{'Please contact your network adminstrator at'}; print " $adminemail
\n "; print $lex{'Please record the following error:'}. "$DBI::errstr;

\n"; print "

". $lex{'Back to Discipline Page'}. "

"; } print "";