You need to have your script operate in different modes.  You do this by 
passing an argument when you call your script to tell the script what it is 
supposed to do.  So in this case, if the script is called with out any 
arguments, it will display the form, as follows:

http://www.sample.com/sample.pl

Then, in your HTML, add a hidden field to your form that provides the 
action you want to do like this:

<FORM NAME='test' ACTION='sample.pl'>
<FIELD TYPE='hidden' NAME='action' VALUE='1'>

Now, when you enter the Perl script again, and you extract the parameters, 
you will have a parameter called "action" that has a value of 1.  Do a 
conditional test for this value, and if the value is not assigned, as in 
the original case, just display the form.  If the action is set to 1, do 
your database update, and then show the form again with the new values.  If 
the user hits the reload button, the page will reload, but the action will 
not be set causing the page to show with first doing a reset.  Only if they 
hit the submit button will the hidden variable be passed to the script 
causing the action value to be set.  Hope this helps.  BTW, all this stuff 
you are wanting to do is MUCH MUCH MUCH easier in PHP which is quite Perl 
like is some respects, but is so much easier and more efficient, and it 
works GREAT with MySQL because is has a bunch of MySQL functions built 
in.  Most top web applications these days are developed around what is 
called LAMP, which stands for Linux/Apache/MySQL/PHP.  This is the winning 
combination.

-Ken


At 01:42 AM 6/6/01 -0500, Dawn H wrote:
>I've written a couple of scripts and have a thing that I haven't quite
>figured out. If anyone can shed light on this, I'd appreciate it.
>
>When a person submits a form that inserts a record into the database, if
>they then refresh the page that comes up after the submit, the record will
>be submitted a second time.  I suppose this is due to the fact that the
>subroutine that is called with the submit contains both the write to
>database bit and the view bit. So refreshing causes a repeat of both items.
>
>How can I do this without that problem?
>
>Thanks in advance,
>Dawn H
>It's practically impossible to look at a penguin and feel angry. --Joe Moore
>
>
>http://www.rdcss.com/ - R&D Computer Solutions
>http://wow.cooncheese.com/ - WOW.CoonCheese.com
>http://dpenguin.rdcss.com/ - Cornucopia
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to