There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijack hijackthis internet internet explorer itunes laptop malware monitor mouse network networking outlook 2007 power printer problem ram router screen slow sound spyware trojan usb virus vista vista 32-bit windows windows xp windowsxp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
please help -- where are my variables??


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. Enjoy!

Closed Thread
 
Thread Tools
Auroralei's Avatar
Junior Member with 16 posts.
 
Join Date: Jun 2004
Experience: Perl greenie
12-Sep-2004, 04:35 PM #1
please help -- where are my variables??
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>
mark007's Avatar
Member with 44 posts.
 
Join Date: Sep 2004
Location: York, UK
Experience: Advanced
15-Sep-2004, 07:32 AM #2
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.

Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:35 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.