projects
/
technostate.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bah
[technostate.git]
/
cgi
/
sets.cgi
diff --git
a/cgi/sets.cgi
b/cgi/sets.cgi
index
e94a25b
..
7be457d
100755
(executable)
--- a/
cgi/sets.cgi
+++ b/
cgi/sets.cgi
@@
-1,5
+1,5
@@
#!/usr/bin/perl -Tw
#!/usr/bin/perl -Tw
-# $Id: sets.cgi,v 1.
1 1999-04-22 05:04:56 trose
Exp $
+# $Id: sets.cgi,v 1.
4 1999-04-22 06:06:16 ivan
Exp $
# Copyright (c) 1999 Ivan Kohler. All rights reserved.
# This program is free software; you can redistribute it and/or modify it under
# the same terms as perl itself
# Copyright (c) 1999 Ivan Kohler. All rights reserved.
# This program is free software; you can redistribute it and/or modify it under
# the same terms as perl itself
@@
-9,7
+9,7
@@
use vars qw ( $data_source $user $password $table @fields
$cgi $dbh
);
use subs qw( print_form );
$cgi $dbh
);
use subs qw( print_form );
-use CGI;
+use CGI
qw(tr th td)
;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
@@
-27,42
+27,47
@@
$dbh = DBI->connect( $data_source, $user, $password )
unless ( $cgi->param('magic') ) { #first time through
unless ( $cgi->param('magic') ) { #first time through
- my $sth = $dbh->do( "SELECT * FROM PERSONS" ) or die $dbh->errstr;
+ my $sth = $dbh->prepare( "SELECT * FROM $table" )
+ or die $dbh->errstr;
+ my $rv = $sth->execute;
+ die $sth->errstr unless $rv;
- print $cgi->header,
- $cgi->start_html('
Person
listing'),
- $cgi->h1('
Person
listing'),
+ print $cgi->header
( '-expires' => 'now' )
,
+ $cgi->start_html('
Set
listing'),
+ $cgi->h1('
Set
listing'),
;
unless ( $sth eq '0E0' ) {
;
unless ( $sth eq '0E0' ) {
+ my @columns = @{ $sth->{'NAME'} };
+
print $cgi->start_table,
$cgi->tr(
map {
$cgi->th($_)
print $cgi->start_table,
$cgi->tr(
map {
$cgi->th($_)
- } @{$sth->{NAME}}
- ),
- map {
- $cgi->tr(
- map {
- $cgi->td( $_ )
- } @{ $_ }
- )
- } @{ $sth->fetchall_arrayref },
- $cgi->end_table,
+ } @columns
+ )
;
;
+
+ my %hash = ();
+ my $hashref = undef;
+ while ( $hashref = $sth->fetchrow_hashref ) {
+ %hash = %{$hashref};
+ print $cgi->tr( map { $cgi->td( $hash{$_} ) } @columns );
+ }
+ print $cgi->end_table;
}
$cgi->param('magic', 'new_form');
}
$cgi->param('magic', 'new_form');
- print '<P><A HREF="', $cgi->self_url, '">Add new
person
</A>';
+ print '<P><A HREF="', $cgi->self_url, '">Add new
set
</A>';
print $cgi->end_html;
exit;
} elsif ( $cgi->param('magic') eq 'new_form' ) {
print $cgi->end_html;
exit;
} elsif ( $cgi->param('magic') eq 'new_form' ) {
- $cgi->param('
PERSON
_ID', 0);
+ $cgi->param('
SET
_ID', 0);
$cgi->param('magic', 'process_form');
$cgi->param('magic', 'process_form');
- &print_form( $cgi, "Add
person
" );
+ &print_form( $cgi, "Add
set
" );
exit;
} elsif ( $cgi->param('magic') eq 'process_form' ) {
exit;
} elsif ( $cgi->param('magic') eq 'process_form' ) {
@@
-73,10
+78,13
@@
unless ( $cgi->param('magic') ) { #first time through
$cgi->param( $field, $1);
}
}
$cgi->param( $field, $1);
}
}
- my $statement = 'INSERT INTO PERSONS ( '.
+ $cgi->param('FILESIZE', 0);
+ $cgi->param('DOWNLOADS', 0);
+
+ my $statement = "INSERT INTO $table ( ".
join(', ', @fields ).
' ) VALUES ( '.
join(', ', @fields ).
' ) VALUES ( '.
- join( ', ', map { $
cgi->param($_
) } @fields ).
+ join( ', ', map { $
dbh->quote($cgi->param($_)
) } @fields ).
' )'
;
my $sth = $dbh->prepare($statement)
' )'
;
my $sth = $dbh->prepare($statement)
@@
-84,9
+92,10
@@
unless ( $cgi->param('magic') ) { #first time through
my $rv = $sth->execute;
die $sth->errstr unless $rv;
my $rv = $sth->execute;
die $sth->errstr unless $rv;
- print $cgi->header,
- "person added?"
- ;
+ my $url = $cgi->url;
+ $url =~ s/^\/[\/]+$//;
+ print $cgi->redirect($url);
+
}
sub print_form {
}
sub print_form {