#!/usr/bin/perl -Tw
-# $Id: persons.cgi,v 1.8 1999-04-22 06:06:16 ivan Exp $
+# $Id: persons.cgi,v 1.9 1999-04-22 06:24:57 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
foreach $field ( @fields ) {
if ( $cgi->param( $field ) ) {
$cgi->param( $field ) =~ /^(.*)$/;
- $cgi->param( $field, $1);
+ my $param = $1 || 0;
+ if ( (DBI::looks_like_number($param))[0] ) {
+ $cgi->param( $field, $param );
+ } else {
+ $cgi->param( $field, $dbh->quote($param) );
+ }
}
}
my $statement = "INSERT INTO $table ( ".
join(', ', @fields ).
' ) VALUES ( '.
- join( ', ', map { $dbh->quote($cgi->param($_)) } @fields ).
+ join( ', ', map { $cgi->param($_) } @fields ).
' )'
;
my $sth = $dbh->prepare($statement)