Perl and refresh button, save twice?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl and refresh button, save twice?
# 1  
Old 11-14-2004
Perl and refresh button, save twice?

Hi guys,

I am writing a simple script save_me.cgi that can save the data in form.html into a txt (data.txt)file.
But when user click "refresh" button one the browser on page save_me.cgi, the data will be save again in the data.txt.

could someone help me on this issue?

a studpid way might be check the whole file and see any repeat records. but I would try to avoid this if possible.

Thanks
# 2  
Old 11-15-2004
You could use a POST method to submit the data so the browser will popup a confirmation request to the user when refreshing that page.

You could also have the script redirect the browser to a different page when outputting the result of the POST.

And there are some HTML meta tags that could be used to solve that specific problem.. but I can't remember them.
# 3  
Old 11-15-2004
You may use session (such as CGI::Session) to handle this. Generate a random ID as hidden form parameter in your form, and write it to the session when finished updating the records. Before each save operation, check whether the ID exists in the session. If so, the page has been refreshed; otherwise, commit it.

Form parameters can be refreshed, but session entries are created on the server so they are a reliable source to detect occurrences of page refreshes.
# 4  
Old 11-23-2004
thans

guys
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - start search by using search button or by pressing the enter key

#Build label and text box $main->Label( -text => "Input string below:" )->pack(); $main->Entry( -textvariable => \$text456 )->pack(); $main->Button( -text => "Search", -command => sub { errchk ($text456) ... (4 Replies)
Discussion started by: popeye
4 Replies

2. Shell Programming and Scripting

Create download button using perl CGI

Hi, I want to insert in a page a .html button that - once it is clicked - opens a save file dialog box by using perl CGI . I know that to create a link to do that I've done : print $cgi->p ( { -class => 'linc' },);I want to do something similar for a download button (0 Replies)
Discussion started by: black_fender
0 Replies

3. Shell Programming and Scripting

Perl - radio button processing

Hi, I am hoping to get some help on perl. I am trying to process a HTML radio button selected value in perl. Basically What I am trying to do is 1. I have some radio buttons which indicated different colors. 2. I have a list box where I want to populate depending on the selected radio button... (1 Reply)
Discussion started by: devtakh
1 Replies

4. Shell Programming and Scripting

Perl - save results to output file.

Can any one please help, the code works...I want the output of $result to be saved in an output.txt file which is lcoated in c:\\temp\\output.txt. $filepath="C:\\temp\\ip.txt"; open (HOSTLIST,"$filepath"); @hosts=(<HOSTLIST>); foreach $host(@hosts) { $results = `nslookup... (1 Reply)
Discussion started by: sureshcisco
1 Replies

5. Web Development

include virtual perl-script - submit button opens a new page..

hello 2 all I can't understand how to insert a perl-script into .shml in a right way. <form> should be working but it's not doing that: <!--#include virtual="/cgi-bin/script.cgi?filename"--> filename is a name of the file which script is using the script is used for a score show (the number... (3 Replies)
Discussion started by: tip78
3 Replies

6. Shell Programming and Scripting

include virtual perl-script - submit button opens a new page..

hello 2 all I can't understand how to insert a perl-script into .shml in a right way. <form> should be working but it's not doing that: <!--#include virtual="/cgi-bin/script.cgi?filename"--> filename is a name of the file which script is using the script is used for a score show (the number... (0 Replies)
Discussion started by: tip78
0 Replies

7. Shell Programming and Scripting

perl-data from file save to multidimensional array

i have a file,like 1 3 4 5 6 7 8 9 i want to save it into an array. and then i want to get every element, because i want to use them to calculate. for example: i want to calculate 1 + 3. but i cannot reach my goal. open (FILE, "<", "number"); my @arr; while (<FILE>){ chomp;... (1 Reply)
Discussion started by: pp-zz
1 Replies

8. UNIX for Dummies Questions & Answers

Changing middle mouse button for pasting to right mouse button in cygwin rxvt

Hi, I'm using rxvt in Cygwin and I'm wondering how to change my mouse bindings from the middle button for pasting to the right button. The main reason why I want to do this is because my laptop doesn't have a middle mouse button. Thanks for any help! (2 Replies)
Discussion started by: sayeo
2 Replies

9. UNIX for Dummies Questions & Answers

Refresh ls list on screen (auto-refresh)?

I am looking for a way to issue a command or string of commands to repeatedly display new files that are written to the directory. I usually use ls -ltr to see the newest files at the bottom of the screen. I would like to automate this command to refresh what is displayed every second or so. Can... (3 Replies)
Discussion started by: skidude
3 Replies

10. UNIX for Dummies Questions & Answers

Script for using the Back button and the Close button

Here's a question I have for anyone that might be able to help me: I can write a html script that will allow the user to return to the previous page using the back button, and I can write a script that will allow the user to return to the previous page using the close button, but...is there a... (1 Reply)
Discussion started by: mdgibson
1 Replies
Login or Register to Ask a Question