1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

please help -- where are my variables??

Discussion in 'Software Development' started by Auroralei, Sep 12, 2004.

Thread Status:
Not open for further replies.
  1. Auroralei

    Auroralei Thread Starter

    Joined:
    Jun 10, 2004
    Messages:
    16
    I have a very simple script and a very simple form.

    My problem is that when i send the form variables to the script, I can't do anything with them. See the script below: All I want it to do is print "The item number is "item_number". What I get is "The item number is (blank)"

    Can someone please tell me what the problem is?

    #!/usr/bin/perl
    use strict;
    use lib qw(C:/Perl/lib);
    use CGI qw:)standard escapeHTML);
    use DBI;

    my $query;
    my %form;
    my $item_name;
    my $item_number;

    my @pairs;
    my $pair;
    my $name;
    my $value;


    read (STDIN, $query, $ENV{'CONTENT_LENGTH'});

    %form = &parse;


    $item_name = $form{item_name};
    $item_number = $form{item_number};


    &deliver_product;


    sub parse {
    @pairs = split(/&/, $query);
    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;
    }


    sub deliver_product {


    print <<EOF;
    Content-Type: text/html\n\n

    <html>
    <head>
    <title></title>
    </head>
    <body>
    The item number is $item_number
    </body>

    </html>
    EOF
    }
    }

    exit (0);




    And here's the form I use:

    <HTML>
    <head>
    </head>

    <body>

    <form method="post" action="http://www.worldwidetattoodesigns.com/cgi-bin/shortshort.pl" target="_blank">
    <input type="hidden" name="item_name" value="Fairy Girl on Ladybug Flower">
    <input type="hidden" name="item_number" value="BPFAGI0002FWP">
    <input type="submit" value="Test IPN">
    </form>

    </BODY>
    </HTML>
     
  2. mark007

    mark007

    Joined:
    Sep 15, 2004
    Messages:
    40
    Any reason why you specifically want to use Perl?

    I'm rather rusty on Perl but could look later if needs be. You could reduce the size of the script to almost nothing with PHP though.

    :)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/273168

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice