New Perl User needs help with POST in perl

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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. ...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default RE: 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,
    use CGI 'param';
    my $email = param('email');
    dbm file??
    perldoc -f open
    > then places a 1 next to it like an array? Some of the data in
    A one next to what again?
    > 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:
    Perhaps if you explain what you are trying to do with the
    email address we can help better.

    HTH

    Dmuey
    Dan Muey Guest

  4. #3

    Default 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:
    > 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.
    >
    HI,

    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&param2=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

  5. #4

    Default 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

    > 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,
    use CGI 'param';
    my $email = param('email');
    dbm file??
    perldoc -f open
    > then places a 1 next to it like an array? Some of the data in
    A one next to what again?
    > 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:
    Perhaps if you explain what you are trying to do with the
    email address we can help better.

    HTH

    Dmuey

    Chris Reddekopp Guest

  6. #5

    Default Re: New Perl User needs help with POST in perl

    Chris Reddekopp wrote:
    > 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.
    It is not always a good idea to decide in advance what tools you need for the
    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.
    > 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.
    if ($repeat->{$visitor}) {
    ...
    } else {
    ...
    }
    > 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.
    First you have to define the data and its shape. Once you have done this, the
    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

Posting Permissions

  • You may not post new threads
  • You may 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