Hi all,
I want to modify the occupation table for a holiday house. This is my (quite naive)
approach:
<h1>Belegung 2004</h1>
<table>
<tr>
<th></th> <th>1</th> <th></th> <th></th> <th></th> <th>5</th> <th></th>
<th></th> <th></th> <th></th> <th>10</th> <th></th> <th></th> <th></th> <th></th>
<th>15</th> <th></th> <th></th> <th></th> <th></th> <th>20</th> <th></th> <th></th>
<th></th> <th></th> <th>25</th> <th></th> <th></th> <th></th> <th></th> <th>30</th>
<th></th>
</tr>
<tr><th>Januar</th><td name="Januar_1" class="frei"> </td><td name="Januar_2"
class="belegt"> </td><td name="Januar_3" class="belegt"> </td><td
name="Januar_4" class="frei"> </td><td name="Januar_5"
class="frei"> </td><td name="Januar_6" class="frei"> </td>
Table cells of class "belegt" appear in red, class "frei" appears in green. Now I have
an HTML form like this:
<form action="../cgi-bin/beleg_form.pl" method="post" accept-charset="iso-8859-1">
<table>
<tr>
<th></th> <th>1</th> <th></th> <th></th> <th></th> <th>5</th> <th></th>
<th></th> <th></th> <th></th> <th>10</th> <th></th> <th></th> <th></th> <th></th>
<th>15</th> <th></th> <th></th> <th></th> <th></th> <th>20</th> <th></th> <th></th>
<th></th> <th></th> <th>25</th> <th></th> <th></th> <th></th> <th></th> <th>30</th>
<th></th>
</tr>
<!-- Januar -->
<tr><th>Januar</th>
<td class="zentral"><input type="checkbox" name="Januar_1" /></td>
<td class="zentral"><input type="checkbox" name="Januar_2" /></td>
<td class="zentral"><input type="checkbox" name="Januar_3" /></td>
<td class="zentral"><input type="checkbox" name="Januar_4" /></td>
<td class="zentral"><input type="checkbox" name="Januar_5" /></td>
<td class="zentral"><input type="checkbox" name="Januar_6" /></td>
[...]
This is sent to the following script:
#!/usr/bin/perl -w
# beleg_form.pl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
# configuration:
my $q = new CGI;
my %date_hash;
for ($q->param) {
$date_hash{$_} = $q->param($_);
}
open PLAN, "../deutsch/belegung.html" or die "Cannot open the belegung.html: $!";
my $beleg_plan = join '', <PLAN>;
close PLAN;
for (keys %date_hash) {
if ($date_hash{$_} eq "on") {
$beleg_plan = s#(name="$_" class=").+?"#${1}belegt"#;
}
else {
$beleg_plan = s#(name="$_" class=").+?"#${1}frei"#;
}
}
open PLAN, "> ../belegung.html";
print PLAN $beleg_plan;
close PLAN;
The idea is that the entries from the form are read into a hash which then runs over
the existing "belegung.html" and changes the table cells accordingly.
Now the tricky thing: As long as there was an error in my script, it was displayed in
my browser (thanks to CGI::Carp). But as soon as I eliminated the obvious errors, I
get an Internal Server Error (testing on my ISP's linux web server and on my local OS
X box, both running Apache).
Can anybody see my mistake here?
Thanks,
Jan
--
These are my principles and if you don't like them... well, I have others. - Groucho
Marx
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>