Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    New Coder
    Join Date
    Jan 2011
    Location
    Dallas
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sorry. It was your perl code. I named it:


    Submitanswer.pl


    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   = "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;

  2. #17
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    It works correctly for me.

    Are you calling the script directly in the browser, or are you filling in the form fields on the html page and submitting the form?

  3. #18
    New Coder
    Join Date
    Jan 2011
    Location
    Dallas
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  4. #19
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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.

  5. #20
    New Coder
    Join Date
    Jan 2011
    Location
    Dallas
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    back to square one

    "Submit Visitor Info to text or hex file" was the title of this thread. That would have worked.

    After a week i am advised that i am an idiot for thinking the perl was supposed to work.

    If there is a way to make it work you are not going to tell me. Your sponsors sell visitor forms.

  6. #21
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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?

  7. #22
    New Coder
    Join Date
    Jan 2011
    Location
    Dallas
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    approaching answer?

    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: $!";

  8. #23
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Code:
    print $fh "Name=$name,Value=$params{$name}\n";
    You also need to take the 'my' off the close satement.

  9. #24
    New Coder
    Join Date
    Jan 2011
    Location
    Dallas
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hmmmm?

    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.

    Thank you for getting this to work....


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •