Hello Gary –

Yes, my CGI generates the form on the fly.  Its like the script is run on 
load and processes the data immediately.  Maybe my code is wrong.  It’s 
driving me crazy!  Here is my code below.


thanks in advance -

--------------------------

#!/usr/bin/perl


#Evaluation Questions for survey
use DBI;
use DBD::mysql;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);

#Conntect to DB
my $dbh= DBI->connect("DBI:mysql:bookstore","usrname","psswd")
                                or die "Could not make connection to database.";
my $usertype= param('usertype');

print header;

list();
#starts from
sub list
        {

print qq|<html>
        <head>
        </head>
                <title>Evalutation Survey</title>
                <body>
        <table width="700" align="center">
                <tr>
                        <td>
                        <h2><center><font color="navy"> Survey <br></font></h2>
        <p align="justify">Thank you for visiting my web site.</p>

<p align="justify">By participating in this survey the information you 
provide will be most useful in helping me complete the design of my 
site</b></p>

<form>
<hr><b>PART ONE - Getting to know You and Your Computer Environment</b><hr>
                        <ol>
                        <li> <h4>Currently, my position is ____.</h4>

                                <input type="radio" name="usertype" 
value="medst">Medical student
                                <br>
                                <input type="radio" name="usertype" 
value="resid">Resident
                                <br>
                                <input type="radio" name="usertype" 
value="fellow">Fellow
                                <br>

<b>THANK YOU </b>very much for your help with this survey.  Please click 
Submit to send us your responses.  T
<br><br><center>
<input type="submit" value="submit"">
&nbsp; &nbsp;
                                <input type="reset" value="reset"></center>
                </form>
                </td>
                </tr>
        </table>
                </body>

</html>|;

answer();
        }

#writes to DB
sub answer
                {
                $cmd = qq|insert into survey (usertype) values ("$usertype")|;
                $dbh->do($cmd);
                }

#end of program
-----------------------------------------------

>From: Gary Stainburn <[EMAIL PROTECTED]>
>To: "David Draley" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
>Subject: Re: perl help!!
>Date: Thu, 7 Jun 2001 11:03:20 +0100
>
>Hi David,
>
>I don't quite understand this one.  If your script works when the form
>is submitted, then your server/cgi-bin/perl seem to be set up correctly.
>
>Does the same CGI generate the form and accept it back?  If so, then
>them problem is in your CGI's logic.  I do the same thing here, and
>right at the top I check to see if the form's submit button's field
>exists.  If not, then the CGI's called for the first time and I simply
>generate the form and exit.
>
>If the submit button data does exist, then it's responding to the form,
>at which point I validate the form details.  Only after validating the
>data do I call the DB update routeines.
>
>If the CGI is not used to create the form in the first place, then I
>have no idea why it's getting called when someone clicks the refresh
>button.
>
>Gary
>On Wednesday 06 June 2001  8:16 pm, David Draley wrote:
> > is there a way to call a perl sub routines using a FORM when a
> > "submit" button is clicked?
> >
> > I am trying to push data to a mySQL database table and when my form
> > is loaded into the browser or is "refreshed" the browser runs through
> > my cgi script and pushes "null" values to the table.  Once the form
> > is filled and the user clicks the form "submit button" the form works
> > and pushes the correct values.
> >
> >
> > thanks
> > david
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>--
>Gary Stainburn
>
>This email does not contain private or confidential material as it
>may be snooped on by interested government parties for unknown
>and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Reply via email to