#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser); # remove this after debugging the script
my $cgi = CGI->new;
my %params = $cgi->Vars;
my $title = "Get Information From A URL";
print $cgi->header,
$cgi->start_html($title),
$cgi->h1($title),
$cgi->hr;
foreach my $name ( keys %params ) {
print $cgi->p("Name = $name, Value = $params{$name}\n");
}
print $cgi->end_html;
I go to the visitor form on one html page, called Visitor Form.html.
I submit info. I leave that page.
I open up my second web page with a secret name, that calls your perl routine. After clicking the button, it prints the heading and the horizontal row, but it doesn't print the info I submitted. I assume this page works and the other doesn't.
Why would you think that would do anything useful?
The Form.html page needs to submit the data directly to the perl script I provided, i.e., it's the script you point to in the action attribute of the form. Or, the script that it points to needs to save the data to a file or database and then some other script could read-in that data from that file or database.
I did tell you what you needed to do (i.e., use the open function to open a filehandle and print the data to that filehandle), but due to the fact that you left out some very important details of what you were actually doing we ended up on a tangent.
Have you read the perldoc documentation that I pointed you to?
Do you still need help writing the data to the file? Which needs to be done by the script that the form is submitted to.
At this point, are looking to learn how to do this, or are you wanting someone else to write it for you?
Thanks, I am starting to get this a little.
I think I debugged this, except line 16 gets error message I can't figure out.
Code:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser); # remove this after debugging the script
my $cgi = CGI->new;
my %params = $cgi->Vars;
my $title = "Information From Visitors";
open(my $fh, ">>", "visitorinput.txt")# ">>" for append?
or die "cannot open > visitorinput.txt: $!";
foreach my $name (keys %params) {
print my $fh->("Name"=$name,"Value"=%params{$name});#error here?
}
close(my $fh)
|| warn "close failed: $!";
I changed the code. I went to visitor form, and entered info. It came back with some message, not like the error message, saying request not fulfilled or something. I opened the text file and the info was there, no problem. I changed the permission, maybe that will stop the message.