Professional Web Applications Themes

help with a simple guestbook :( - PERL Miscellaneous

shimrah wrote: > I'm a green, green newbie, and I'm having trouble getting this > simple script to work. It's supposed to be a simple guestbook, but > only the FEEDBACK gets posted to the log.html file, while the EMAIL > and NAME are left blank. It's because the line $FORM{$name} = $value; is outside the foreach loop. I assume that you are writing the script yourself as a learning exercise. There seem to be quite a few things that you should know before making such a self-made script available to the 'world'. I think it would be a good ...

  1. #1

    Default Re: help with a simple guestbook :(

    shimrah wrote:
    > I'm a green, green newbie, and I'm having trouble getting this
    > simple script to work. It's supposed to be a simple guestbook, but
    > only the FEEDBACK gets posted to the log.html file, while the EMAIL
    > and NAME are left blank.
    It's because the line

    $FORM{$name} = $value;

    is outside the foreach loop.

    I assume that you are writing the script yourself as a learning
    exercise. There seem to be quite a few things that you should know
    before making such a self-made script available to the 'world'. I
    think it would be a good idea to study and learn from the guestbook
    script that is available at [url]http://nms-cgi.sourceforge.net/scripts.shtml[/url]

    Good luck! And have fun. :)

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]

    Gunnar Hjalmarsson Guest

  2. #2

    Default Re: help with a simple guestbook :(

    shimrah <shimrahhotmail.com> wrote:
    > I'm a green, green newbie,
    > Any help would be appreciated...
    > #!/usr/bin/perl

    Ask for all the help you can get:

    use strict;
    use warnings;

    > # The following accepts the data from the form
    >
    > if ($ENV{'REQUEST_METHOD'} eq 'POST') {

    I can see the problem in your form processing code, but I am
    not going to help fix it.

    Use the CGI.pm module for processing the form values instead.

    > print GUESTBOOK "$FORM{name} -- ";
    > print GUESTBOOK "$FORM{email}";
    > print GUESTBOOK "$FORM{feedback}";
    print GUESTBOOK param('name'), ' -- ';
    print GUESTBOOK param('email');
    print GUESTBOOK param('feedback');


    --
    Tad McClellan SGML consulting
    [email]tadmcaugustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  3. #3

    Default Re: help with a simple guestbook :(

    shimrah wrote:
    > Hi,
    >
    > I'm a green, green newbie, and I'm having trouble getting this simple
    > script to work. It's supposed to be a simple guestbook, but only the
    > FEEDBACK gets posted to the log.html file, while the EMAIL and NAME
    > are left blank.
    >
    > Any help would be appreciated...
    >
    > - - -
    >
    > #!/usr/bin/perl
    >
    > use CGI::Carp qw(fatalsToBrowser);
    >
    > # The following accepts the data from the form
    >
    > if ($ENV{'REQUEST_METHOD'} eq 'POST') {
    >
    > read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    >
    > pairs = split(/&/, $buffer);
    >
    > foreach $pair (pairs) {
    > ($name, $value) = split(/=/, $pair);
    > $value =~ tr/+/ /;
    > $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    > }
    >
    > $FORM{$name} = $value;
    >
    >
    > # The following code posts the log entry
    >
    > my $Guestbook="log.html";
    > open(GUESTBOOK,">> $Guestbook") or die "Could not open
    > $Guestbook!\n";
    >
    > print GUESTBOOK "From:";
    > print GUESTBOOK "$FORM{name} -- ";
    > print GUESTBOOK "$FORM{email}";
    > print GUESTBOOK "$FORM{feedback}";
    > print GUESTBOOK
    >
    "--------------------------------------------------------------------------------";
    <SNIP>

    I've not seen a CGI script like this before, but ...

    Are you sure the keys are correct? Try replacing the log entry code with
    something like:

    foreach my $key (sort keys %FORM);
    my $value = $FORM{$key};
    print GUESTBOOK "$key: $value";
    }

    This'll show you exactly what data exists within your hash.

    In addition to that, you probably want to be using STRICT and WARNINGS.

    HTH,

    Garry


    --

    Please respond to the group, not via e-mail.
    For a valid e-mail address, please replace the numbers with the closest
    resembling letters.
    Garry Short Guest

Similar Threads

  1. Guestbook Help Please
    By professorsr in forum Macromedia Flash Data Integration
    Replies: 2
    Last Post: October 14th, 11:33 AM
  2. a simple guestbook
    By third man in forum Macromedia Flash Data Integration
    Replies: 2
    Last Post: July 30th, 02:15 AM
  3. Guestbook
    By Duffy07 in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: June 21st, 12:46 PM
  4. guestbook tutorials
    By RJweb in forum Macromedia ColdFusion
    Replies: 1
    Last Post: May 31st, 02:56 AM
  5. Hep req. with PHP and MySQL - simple guestbook
    By Phlarmf in forum PHP Development
    Replies: 3
    Last Post: September 21st, 08:17 PM

Bookmarks

Posting Permissions

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

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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139