Ask a Question related to PERL Beginners, Design and Development.
-
Perldiscuss - Perl Newsgroups And Mailing Lists #1
New Perl User needs help with POST in perl
I have written my HTML code to where it uses POST to collect information.
Where do I start to write a script that collects the data from the web
site, places the input into a dbm file, then places a 1 next to it like an
array? Some of the data in the file will have zeros, while the ones that
are inputted in the site will have a 1.
Here is the end of the HTML code that uses POST:
(Hope it displays properly)
#<form action="input_getter.pl" method="post">
#<font size="4" face="Times New Roman">Please enter your full Email
address here:</font><br>
#<input type="text" name="email" maxlength="30">
#<input type="submit" name="submit">
#</form>
Perldiscuss - Perl Newsgroups And Mailing Lists Guest
-
CGI::StringDB Embedding perl data structures in an HTML post.
Howdy, Wondering if anybody has already done something similar. I expect yes. I wrote a module that has functions for ecoding and decoding... -
Post Script - Hylafax - Text File - perl
I want to write a script that takes piped input and then fills out a purchase order form that can then be sent to Hylafax as a postscript file. ... -
Off Topic: Active Perl Native Windows / cygwin perl
I have both activestate windows native perl installed and the default cygwin perl. How can I have the cygwin shell use the windows perl rather... -
perl CGI related: form post failure
Hello, I am not sure it is a good question for the group(s): I encountered a problem for my website form (method="post"): people have a... -
Effeciency question - perl scripts v's perl exe's
Max Adams wrote: The only existing Perl compiler is part of perl. Anything else is just a packager that puts a perl, required modules, and the... -
Dan Muey #2
RE: New Perl User needs help with POST in perl
> I have written my HTML code to where it uses POST to collect
use CGI 'param';> information. Where do I start to write a script that collects
> the data from the web site, places the input into a dbm file,
my $email = param('email');
dbm file??
perldoc -f open
A one next to what again?> then places a 1 next to it like an array? Some of the data in
Perhaps if you explain what you are trying to do with the> the file will have zeros, while the ones that are inputted in
> the site will have a 1.
>
> Here is the end of the HTML code that uses POST:
email address we can help better.
HTH
Dmuey
Dan Muey Guest
-
Wolf Blaum #3
Re: New Perl User needs help with POST in perl
For Quality purpouses, PerlDiscuss - Perl Newsgroups and mailing lists 's mail
on Thursday 29 January 2004 23:49 may have been monitored or recorded as:HI,> I have written my HTML code to where it uses POST to collect information.
> Where do I start to write a script that collects the data from the web
> site, places the input into a dbm file, then places a 1 next to it like an
> array? Some of the data in the file will have zeros, while the ones that
> are inputted in the site will have a 1.
>
try the CGI.pm modul ([url]http://search.cpan.org[/url]).
It takes care of all your IO stuff. Use it in OO fashion (like below) or even
in function oriented fashion (like explaind at cpan).
-----snip-------
#!/usr/bin/perl
#input_getter.pl
use strict;
use warnings;
use CGI qw /standard/;
my $cgi = new CGI; #new CGI object
my @params=$cgi->param; #get all params (that came via post or get...)
print $cgi->header, #print a response
$cgi->start_html('Results'),
$cgi->h1('you entered:'),
$cgi->start_ul;
foreach (@params) { #I assume all you data come as
#param1=value1¶m2=value2 format
#no arrays returned (as for multiple select boxes and so)
print $cgi->li("$_ => ",$cgi->param($_));
}
print $cgi->end_ul,
$cgi->end_html;
------snap--------------
returns to the caller
------snip----------
Content-Type: text/html; charset=ISO-8859-1
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"><head><title>Results</title>
</head><body><h1>you entered:</h1><ul><li>email => [email]peter@pan.org[/email]</li></ul></
body></html>
------snap------------
which looks pretty much like valid html.
However, as browsers only return parameters, for which values were entered,
dont do something like using the foreach loop above in modified form to eter
you data in a db, unless you have checked that all the parameters you expect
are acctually there (by either doig it server side in your script or using a
little ugly javascript client side).
Hope thats a start, Wolf
Wolf Blaum Guest
-
Chris Reddekopp #4
Re: New Perl User needs help with POST in perl
My apologies. Let me explain better...
In the dbm file will be the array with the customer's email address with a
value of 1 or 0 next to it. This way we have a list of who visited the page
and downloaded the file. When I run the script again to send out the mass
emails pulled from the dbm file, anyone who has a value of 1 will not be
sent the email.
Right now I have the HTML with POST in it to grab the data and the go to the
perl script to add the data to the dbm file. My problem is I do not know how
to start the script and tell it to use the data inputted from the site and
place it into the dbm file.
I hope this helps more and thank you for your help in advance!
Chris
----- Original Message -----
From: "Dan Muey" <dmuey@infiniplex.com>
To: "PerlDiscuss - Perl Newsgroups and mailing lists" <credde@cafes.net>;
<beginners@perl.org>
Sent: Thursday, January 29, 2004 5:34 PM
Subject: RE: New Perl User needs help with POST in perl
use CGI 'param';> I have written my HTML code to where it uses POST to collect
> information. Where do I start to write a script that collects
> the data from the web site, places the input into a dbm file,
my $email = param('email');
dbm file??
perldoc -f open
A one next to what again?> then places a 1 next to it like an array? Some of the data in
Perhaps if you explain what you are trying to do with the> the file will have zeros, while the ones that are inputted in
> the site will have a 1.
>
> Here is the end of the HTML code that uses POST:
email address we can help better.
HTH
Dmuey
Chris Reddekopp Guest
-
R. Joseph Newton #5
Re: New Perl User needs help with POST in perl
Chris Reddekopp wrote:
It is not always a good idea to decide in advance what tools you need for the> My apologies. Let me explain better...
>
> In the dbm file will be the array with the customer's email address with a
> value of 1 or 0 next to it.
job. It sounds like this one is a good candidate, not for an array, but for a
boolean-valued hash. Since Perl is not type-specific, you can use scalars of
any flavor for either keys or values.
if ($repeat->{$visitor}) {> This way we have a list of who visited the page
> and downloaded the file. When I run the script again to send out the mass
> emails pulled from the dbm file, anyone who has a value of 1 will not be
> sent the email.
...
} else {
...
}
First you have to define the data and its shape. Once you have done this, the> Right now I have the HTML with POST in it to grab the data and the go to the
> perl script to add the data to the dbm file. My problem is I do not know how
> to start the script and tell it to use the data inputted from the site and
> place it into the dbm file.
coding will be a snap.
What data? How many items of data does the form send? What are the expected
data types of the data?
We need information like this in order to help you. You need the practice in
defining and articulating problems.
You have two large and complex issues here. You will get there much faster by
breaking the process down into one process at a time, so lets start with the CGI
side.
In brief, the first thing you want to do is include CGI functionality in your
program by calling the CGI module:
use CGI;
then get a CGI object representing current transaction:
my $cgi = CGI->new;
From there, it is largely a design question as to what you do next. You could
fetch all the data into a single hash with the Vars method:
my $junk_heap = cgi->Vars;
or get tehm one at a time.
my $first_name = $cgi->param('first name');
It can be very straightforward, once you have defined what you want.
Joseph
R. Joseph Newton Guest



Reply With Quote

