Reputation: 117
Hi folks I'm trying to do a simple CGI with 2 submit buttons, which do something on a database if you press them. Still I know I'm missing something because i can't seem to get it working.
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<center>
<form action="submit.pl" method="POST">
<input type="submit" name="Inicio" value="Inicio" id="Inicio" Inicio />
<input type="submit" name="Finaliza" value="Finaliza" id="Finaliza" Finaliza />
</form>
</center>
</body>
</html>
submit.pl
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use CGI;
my $q = CGI->new;
my $dsn = "DBI:mysql:database=sms;host=10.0.0.1";
my $dbh = DBI->connect($dsn,"user","password123");
if ($q->param('Inicio'))
my $query = "insert into comienzo_programa (fecha, hora_inicio) values (CURDATE(), CURTIME())";
$dbh->do($query);
} elsif ($q->param('Finaliza')) {
my $query = "insert into comienzo_programa (hora_fin) values (CURTIME()) where fecha=CURDATE()";
$dbh->do($query);
}
I wonder what I am doing wrong. Thank you.
Upvotes: 1
Views: 273
Reputation: 13814
Your <form> is in the <head>, instead of the <body>, which looks peculiar.
Upvotes: 1