the perl cgi list is a better place for this kind of question.  but here is
a little basic info.

if the action of your form is the form itself (in other words, when you
submit, the location you submit to is your script that creates the form
initially) you need to check the parameter value of the submit button.

your submit button should have a name (i don't know the cgi.pm attribute for
the submit button (-name=>"state",-value=>"Add Entry") maybe??

the HTML should look like:
<input type=submit name="submit" value="Add Entry">

at the beginning of your script you should check the value of the parameter
named submit.

use CGI qw/:standard/;
use DBI;

if (param('submit') eq "Add Entry") {

#connect to database
#insert param(name) and param(address) into your table
#give user acknowledgement of success

}

else {

#show your form

}

this is the most basic approach.
If you are interested in learning more Perl, check into CGI::Application
which allows for you to easily create several applications within your one
script (ie. adding entries, showing forms, etc..)

I usually use a subroutine dispatch table which I saw in a cgi book
somewhere once.

some people don't like the branching if/else style when there are several
things your one script might be doing.
Some people separate these functions into two scripts and have the submit
button post the data to a separate script responsible for inputting the data
(your dbi script) and than output a thank you message, or redirect back to
the input form.

I hope this gets you started.  The cgi list would be much more helpful since
that is what your question seems to be about (how to build cgi
applications)..

Job

-----Original Message-----
From: koie smith [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 07, 2002 8:15 PM
To: [EMAIL PROTECTED]
Subject: Another DBI / Web Question


Ok, I'm going to break this apart into different sections so that someone
may can help me figure out what i want to do/how to do it a little better...

Goal : User enters information into a form.pl and the form.pl process's
logon information from a mysql database and sends an email with the
information entered if the logon information is correct.

Information Entered : Customer Number, Password, Name, Email Address,
Message

Logon Information Verified *using DBI* : Customer Number, Password


current code i'm trying to peice together

~~~~~~~~ web form for entering customer number/password ~~~~~~~~
use CGI qw/:standard/;
      print header,
            start_html('Enter Information'),
            h1('Enter Information'),
            start_form,
            "Customer Number : ",textfield('custnum'),p,
     "Password : ",password_field('passwdx1'),p,
            submit,
            end_form,
            hr;

       if (param()) {
           print "Customer Number Entered : ",em(param('custnum')),p,
                 "Password Entered : ",em(param('passwdx1')),
                 hr;
       }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~ DBI code for connecting to the database  ~~~~~~~~

use DBI;

my $dbh = DBI->connect( "dbi:mysql:nextek", "root", "" )
 or die "Can't connect to MySQL Database: $DBI:errstr\n";

$dbh->disconnect(  );
exit;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Ok, this leads to the part i dont know how to do .... I dont know how to
compare the values from the web portion of this code, passwdx1 and custnum
to the values in the mysql database and respond if they are correct or
incorrect, and how to peice the DBI code and the Web code all together in
one file so that it works as one...

If anyone can please help me with this it'd be VERY much appreacited, i'm
learning this to accomplish a small task for our office, its my first step
into perl and so far i see i'm enjoying it alot, but have alot of learning
to do and really want to get this done..

I appreacite any help.
Thanks,
Koie Smith



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to