#!/usr/bin/perl

use DBI;
use CGI;

$param=new CGI;
$tabulka = $param ->param('table');
$radka = $param ->param('radka');
$id = $param ->param('id');

#print "Content-type:text/html\n\n";
&init;
if ($id&&$radka&&$tabulka)
{
$dbh = DBI->connect("$INIT","$LOGIN","$PASS");
$sth=$dbh->prepare("delete from $tabulka where $id=$radka");
$sth->execute;
#while(@rr=$sth->fetchrow_array){}
$dbh->disconnect;
#print " - $sqld , $id11=$radka11";
}

print "Location:view.cgi?table=$tabulka\n\n";



# -------------------------------------------------
sub init
{
 open(F,"dat.conf");
 @o =<F>;
 close(F);
 %COLS=();
 foreach $radek (@o)
 {
  next if $radek=~/^#/; next unless $radek=~/\S/;
  if ($radek=~/^init/i)   {($INIT)=($radek=~/^init\s*=\s*(\S*)/i);};
  if ($radek=~/^login/i)   {($LOGIN)=($radek=~/^login\s*=\s*(\S*)/i);};
  if ($radek=~/^pass/i)   {($PASS)=($radek=~/^pass\s*=\s*(\S*)/i);};
  #if ($radek=~/^tables/i) {($tmp)=($radek=~/^tables\s*=\s*(.*)/i);$tmp=~s/\s*//g;@TABL=split(",",$tmp);};
  #if ($radek=~/^cols/i) {($tmp1,$tmp2)=($radek=~/^cols\s*(.*?)\s*=\s*(.*)/i);$tmp2=~s/\s*//g;$tmp2=~s/,/,/g;$COLS{"$tmp1"}="$tmp2";};
 }
 if(!$INIT) {&err("100","No init string");exit(0);}
}

sub err
{
 print "<br> Error :<b>$_[0]</b> : $_[1]\n";
}