1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| #!/usr/local/bin/perl
use CGI qw/:standard/;
use DBI;
use strict;
my $cgi = new CGI;
my $oracle_host = 'serveur';
my $oracle_dbsid = 'DBName';
my $oracle_user = 'user';
my $oracle_passwd = 'pass';
$cgi->default_dtd('-//W3C//DTD HTML 4.01 Transitional//EN');
print header(-charset =>'ISO-8859-1',
-encoding =>'ISO-8859-1'),
start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),p,
"What's the combination?", p,
checkbox_group(-name=>'words',
-values=>['eenie','meenie','minie','moe'],
-defaults=>['eenie','minie']), p,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),p,
submit,
end_form,
hr;
if (param()) {
print "Your name is ",em(param('name')),p,
"The keywords are: ",em(join(", ",param('words'))),p,
"Your favorite color is ",em(param('color')),
hr;
#TEST INSERT EN BASE
my $name = param('name');
my $req = "INSERT INTO TEST (NOM) VALUES (?)";
my $dbh = DBI->connect("dbi:Oracle:host=$oracle_host;sid=$oracle_dbsid", $oracle_user, $oracle_passwd);
my $sth = $dbh->prepare($req) or die $dbh->errstr;
$sth->execute($name) or die $dbh->errstr;
$sth->finish;
print "Insertion du nom :" .param('name') ."<br>";
#affichage
my $sth = $dbh->prepare("SELECT NOM FROM TEST");
$sth->execute;
print "Affichage en base: \n";
while (my @row = $sth->fetchrow_array) {
print $row[0]."\n";
}
}
end_html(); |
Partager