Thread Link nach Formulareingabe (21 answers)
Opened by Drain at 2003-08-25 18:33

Drain
 2003-08-26 18:57
#1439 #1439
User since
2003-08-21
26 Artikel
BenutzerIn
[default_avatar]
[quote=Strat,26.08.2003, 16:32]1. Kennst Du das Modul CPAN:CGI?
...
durch den folgenden:
Code (perl): (dl )
1
2
3
use CGI;
my $cgi = CGI->new();
my %Formular = $cgi->Vars();

Dann hast du schon mal viel schwierigen Code, der zudem noch fehleranfaellig ist, vermieden.

2.
Code (perl): (dl )
1
2
3
open HTML,'<html.html';
print <HTML>;
close HTML;

Kann da irgenwie das Oeffnen der Datei html.html fehlschlagen?
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
my $file = "html.html";
unless (open (HTML, $file)) {
  print "Fehler: konnte die Datei '$file' nicht oeffnen: $!
";
}
else {
  print <HTML>;
  close HTML;
}
[/quote]
Bin gerade dabei mich in Perl einzuarbeiten. Das mit dem CGI-Modul hab ich prinzipiell schon verstanden, aber zum selbst ausprobieren fehlen mir noch etwas die Grundkenntnisse.

Ich habe es trotzdem mal ausprobiert:
Code (perl): (dl )
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
#!/usr/bin/perl -w

# Formular.pl sends a formated email with formular input (independend of number of fields)
# 25.08.03 (spr)

use strict;
use CGI::Carp qw(fatalsToBrowser);

# Input and format
use CGI;
my $cgi = CGI->new();
my %Formular = $cgi->Vars();

# Output

# HTML-output
my $test = 1;
if( $test != 0) {
        # for testing
        print "Content-type: text/html\n\n";
        print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">', "\n";
        print "<html><head><title>CGI-Feedback</title></head>\n";
        print "<body><h1>Resultate von <i>Formular.pl</i></h1>\n";
        print "<b>Übertragene Daten:</b><br>";
        while (($Name, $Wert) = each(%Formular)) {
                print "Das Formularfeld $Name besitzt den Wert $Wert.<br>\n";
        }
        print "</body></html>\n";
}

Das Ergebnis ist folgendes:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
Software error:
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 25.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 25.
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 26.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 26.
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 93.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 93.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 94.
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 94.
Execution of c:\inetpub\scripts\formular.pl aborted due to compilation errors.

For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.


Zu Punkt 2)
War ein Vorschlag von Ishka zum Laden einer Folgeseite (nach Formularabsenden). Leider klappt das momentan weder so, noch mit redirect.

@renee
Quote
my $test = 0; #  ich versteh nicht so ganz was das soll, übernehme es aber von dir...
if($test != 0){ # kann bei deinem Skript allerdings nie passieren

Ist nur für mich zum Testen gedacht, damit ich mal schnell zwischen den beiden Varianten switchen kann.

View full thread Link nach Formulareingabe