numberwhun 3,509
Recognized Expert Moderator Specialist
Hello everyone! I am dabbling in processing forms using Perl and having only just begun, I am already having problems. Go figure. :-)
Top begin with, here it the form's html, its nothing at all complicated: -
<div id="formcontent">
-
<h3>The New Information Gathering Form</h3>
-
<form action="./cgi-bin/process_form.cgi" method="post">
-
<fieldset>
-
<legend><strong>Personal Information</strong></legend>
-
<label for="firstname">First Name:</label>
-
<input type="text" id="firstname" maxlength="25"/><br />
-
<label for="lastname">Last Name:</label>
-
<input type="text" id="lastname" maxlength="30"/><br />
-
<label>Date Of Birth:</label>
-
<label for="dobmonth" class="date">Month</label>
-
<input type="text" maxlength="2" id="dobmonth" size="2" />
-
<label for="dobday" class="date">Day</label>
-
<input type="text" maxlength="2" id="dobday" size="2" />
-
<label for="dobyear" class="date">Year</label>
-
<input type="text" maxlength="4" id="dobyear" size="4" /><br/>
-
<label>Gender:</label>
-
<input type="radio" name="gender" value="Male" /> <label for="gender" class="sex">Male</label>
-
<input type="radio" name="gender" value="Female" /> <label for="gender" class="sex">Female</label><br />
-
-
</fieldset>
-
<br />
-
<fieldset>
-
<legend><strong>Contact Information</strong></legend>
-
<label for="address1">Address1:</label>
-
<input type="text" id="address1" /><br />
-
<label for="address1">Address2:</label>
-
<input type="text" id="address2" /><br />
-
<label for="city">City:</label>
-
<input type="text" id="city" /><br />
-
<label for="state">State:</label>
-
<input type="text" id="state" /><br />
-
<label for="zipcode">Zip Code:</label>
-
<input type="text" id="zipcode" /><br />
-
<label for="phone">Phone #:</label>
-
<input type="text" id="phone" alt="In the format XXX-XXX-XXXX" /><label class="format">(XXX-XXX-XXXX)</label><br />
-
</fieldset>
-
<br />
-
<fieldset>
-
<legend><strong>Form Control</strong></legend>
-
<input type="submit" value="Submit" class="submit" />
-
<input type="reset" value="Reset Form" />
-
</fieldset>
-
</form>
-
</div>
-
Please know that with the css I have, it will look a lot prettier. If you want to see the form in all its glory, please see this link
If you put in information and hit submit, you will see that it errors. No, there isn't a 500 page as of yet, but that's not the issue. If I execute the script by hand, I get the following error:
[code]
[Mon Aug 18 10:41:57 2008] process_form.cg i: Use of uninitialized value in read at ./process_form.cg i line 22.
[code]
The following is the script that I have put together to process the above form after submission. -
#!/usr/local/bin/perl
-
-
# The following line needed as the host puts a perl
-
# directory in your site home directory that contains
-
# ALL the Perl modules that are installed on the site.
-
# Its basically everything.
-
use lib '/home/jkwebdev/perl';
-
-
##### use statements #####
-
use strict;
-
use warnings;
-
use CGI::Carp qw(fatalsToBrowser);
-
-
##### Variable Declarations #####
-
my @pairs;
-
my $pair;
-
my $value;
-
my $name;
-
my %form;
-
my $buffer;
-
-
#####
-
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;
-
}
-
-
}
-
-
for my $key ( keys %form ) {
-
my $value = $form{$key};
-
print "$key => $value\n";
-
}
-
All I want to do at first is print out all of the values so I can get a visual on it and that isn't even working.
Any help will be greatly appreciated!
Best regards,
Jeff
8 1619 KevinADC 4,059
Recognized Expert Specialist
Why aren't you using the CGI module to get the form data Jeff? - use lib qw(.....);
-
use strict;
-
use warnings;
-
use CGI::Carp qw/fatalsToBrowser/;
-
use CGI;
-
my $q = CGI->new;
-
my $form = $q->Vars;
-
print $q->header(),
-
$q->start_html();
-
foreach my $keys (keys %form) {
-
print "$keys = $form{$keys}<br/>\n";
-
print $q->end_html;
-
exit;
KevinADC 4,059
Recognized Expert Specialist
Is that your website Jeff?
numberwhun 3,509
Recognized Expert Moderator Specialist
Why aren't you using the CGI module to get the form data Jeff?
To tell you the truth, I am pretty much just starting to play with CGI and was going off of a tutorial.
I think that I will go and read through the CGI module and use your example. Thanks!
Jeff
numberwhun 3,509
Recognized Expert Moderator Specialist
Is that your website Jeff?
Why yes, yes it is, but don't take it at face value. Its been around a little while and is severely lacking in the update department. That will change though as I am starting to play with things like Drupal and want to revamp the entire thing. (plus maybe even finish it.) :-)
Regards,
Jeff
KevinADC 4,059
Recognized Expert Specialist
To tell you the truth, I am pretty much just starting to play with CGI and was going off of a tutorial.
I think that I will go and read through the CGI module and use your example. Thanks!
Jeff
You are reading the old tutorial, that site has an updated tutorial using the CGI module. While it is good to know some of the behind the scenes workings of CGI form processing, do not use that code in a live script.
numberwhun 3,509
Recognized Expert Moderator Specialist
You are reading the old tutorial, that site has an updated tutorial using the CGI module. While it is good to know some of the behind the scenes workings of CGI form processing, do not use that code in a live script.
Lovely! You would think that they would take down the old one or at least mark it deprecated or something. Sheesh!! Thanks for the 411, I appreciate it and will check out their other tutorial.
FYI, that link came from a Google. search.
Regards,
Jeff
**update: Ok, I dug out my copy of hooked on phonics and learned that the stuff at the top of the web page in question actually says what you were saying. :-) I think I need sleep!!!
KevinADC 4,059
Recognized Expert Specialist
Why yes, yes it is, but don't take it at face value. Its been around a little while and is severely lacking in the update department. That will change though as I am starting to play with things like Drupal and want to revamp the entire thing. (plus maybe even finish it.) :-)
Regards,
Jeff
hehehe.... don't worry, we've all been there and done that.
eWish 971
Recognized Expert Contributor
hehehe.... don't worry, we've all been there and done that.
At least he used the code tags when posting his code :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Andrew |
last post by:
I have written some code in Java to do some
simple image processing on the server.
Esentially, the program takes a jpeg image
and scales it to a given size.
I need to know what would be involed to convert
this code to Perl since I know very little about
Perl.
|
by: stephenburgess1972 |
last post by:
Would C++ be a good choice for programming server-side applications for
form processing? Or is there a better choice out there?
Thanks.
|
by: Mark |
last post by:
I'm building a web utility to do some processing that will run for several
hours. Assume I have a valid reason for using the web for the utility.
During the process I'd like to display an update on the job's status while
not stopping the process that is running. It does not need to be pretty.
I'd be quite happy with a quick Response.Write("Job has finished consuming
300 of 9356 bananas"); or similar. I don't care if the message is...
|
by: js |
last post by:
Just my curiosity.
Can python beats perl at speed of grep-like processing?
$ wget http://www.gutenberg.org/files/7999/7999-h.zip
$ unzip 7999-h.zip
$ cd 7999-h
$ cat *.htm bigfile
$ du -h bigfile
du -h bigfile
|
by: traravind |
last post by:
Hi all,
I am a newbie to perl programming and am already loving it.. I have a problem with my code in research and am trying to improve the performance by parallel processing some blocks of code.
I have a perl module where I consecutively process data even though there are not dependent on each other.
For example,
my $i= 4;
.
.
| |
by: Ofelia |
last post by:
Hi,
I'm new to this forum and to Perl language but I would like to ask for your help.
I'm working in Linux and the files I need to process are in the format “file.gz”.
I created a script which should decompress, open and then delete nearly 400 files. To do so I use "open FILEPT, "zcat $filename|"".
In the beginning the script works fine, but after about 300 files processed I get an error on Open function:
“proc: Could not open file...
|
by: rustyc |
last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-)
As I said over there:
... for a little side project at home, I'm writing a ham radio web site in uby/Rails. I started it in Perl and gave up on Perl as I went from the 'display the database information on the web page' to the 're-display the information from the database and allow the user to update the database using the web page' stage and realized...
|
by: patelxxx |
last post by:
I have a FORM with allows user to input their name and then user clicks submit which this goes to my .cgi script. Can someone check this .cgi script as the results are not being displayed as expected.
My post_it.cgi:
#!C:/perl/bin/perl.exe
print "Content-type:text/html\n\n";
@values = split(/&/,$ENV{'QUERY_STRING'});
foreach $i(@values) {
|
by: karthikchittur |
last post by:
Hello scripters
Requirement:
I am trying to write a perl script that manipulate a html file. Both the html file and the script are placed at central server. I have scheduled one more script in client PC to run at start-up, that calls this server script with required arguments and the HTML page is updated accordingly. This is not server client architecture but a static server script called from client PC
The problem:
The scripts I have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |