Hi Monks!
I've come to thee again for a cgi - cookie question.
I have a web page which accepts data
<html> <head> <meta http-equiv="Content-Type" content="text/html"> <title>Application</title> <Form method=post name="myForm" action="cgi-bin/details.pl"> ... ... ... <select size="1" name="application" style="font-family: Verdana; font- +size: 13px; border: 1px solid #000000; padding: 1; " size="6" maxleng +th="6" style="background:#D7DFEE;color:blue"> <option></option> <option value="CIDAccounts">CIDAccounts</option> <option value="Column_Financial">Column Financial</option> <option value="IFA">IFA</option> <option value="Imaging-Fax">Imaging-Fax</option> ... ... ... </Form> </body> </html>
The cgi perl script would take the input from the page, validate and enter the details to a text file.
#!c:\perl\bin\perl use strict; use CGI qw(:standard); my $okflag="y"; my @chk; my @InvalidFields = grep {not defined CGI::param($_) or CGI::param($_ +) eq ''} CGI::param(); ... ... ... my @ppl=param('coord'); my $reldate=param('date'); my $apps=param('application'); .. open FH, ">>report_sum.txt" or die "Cant open report_sum.txt Reason: $ +!"; print header; print start_html('Thank you'); print <<EOF; my $writestr=<a single string concatenated based on all the values> print FH $writestr."\n"; close FH; print end_html;
The issue Im facing is that if the user hits refresh in the page which is loaded by the cgi, and hits retry when prompted, the details are again written to the text file.
Since I have no clue about writing cookies, can anyone provide with a complete sample script that will implement the usage of cookies, based on the above scenario, so that there is no re-entry of the same data in the text file. If there's any other way to implement the way, I'll try that too.
Thanks for your time.

Did you ever notice that when you blow in a dog's face, it gets mad at you but when you take him on a car ride,he sticks his head out the window and likes it?

In reply to CGI Cookie by rupesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.