bucklandripers
Technical User
Folks
I think that I have highlighted a problem with using a hyperlink from one perl programme to another.
I am writing software to update records stored on the server.
I have two programs
add_record.pl which receives a request from a display programme to add a new record.
display.pl which
a) receives information from an add_record.pl program
b) updates the records list, and stores them on the server
c) displays the list of records
A request for a new record is initiated in display.pl by the user mousing over a button and clicking. There is a link to add_record.pl via the hyperlink
<!--- New Item --->
<div style="position:absolute; left:20px; top:220px; width:100px; height:20px;">
<a href="/cgi-bin/addto_quality.pl?UserID=$userid"><img src="/newitem.jpg" width="100" height="20" border="0" alt="New Item"></a>
</div>
newitem.jpg is a pretty little button that I cribbed off Frontpage.
So far so good.
I can update the table easily.
The Question arises how to guard against the user pressing the refresh button, sending the data again and updating a copy of the previous record.
I thought a good solution would be to have a refresh switch stored on the server in a text file. When the program add_record.pl was entered, the refresh switch would be set to 1, by opening the text file for writing, printing the new value, then closing the file
open(TXT, ">refresh.txt");
print TXT "1";
close(TXT);
When the data was sent to the display.pl the program display.pl set the switch to -1 before updating the record. A subsequent call to display.pl via the refresh button would find the refresh switch at -1 and no action would be taken, other then to display the records list.
But this idea only partly works. With the simplest of programmes I can flip back and forth between display.pl and add_record.pl. But when I press Refresh Fn5, the program add_record.pl does not set the refresh parameter to 1. It does not seem to open the file.
After many hours trying to understand the problem, I have solved the problem by abandoning the idea of a GET type hyperlink to perl. Instead I created a custom button via
<!--- New Item --->
<div style="position:absolute; left:20px; top:220px; width:100px; height:20px;">
<form method="post" action="/cgi-bin/add_record.pl" >
<input type="hidden" name="UserID" value="$userid" />
<input type = "image" name = "Send2" value="Send2 alt="Send2" src="/newitem.jpg" />
</form>
</div>
where newitem.jpg is the custom button image.
This now works but I dont know why the other method does not. I have used hyperlinks to perl hundreds of times in other contexts with never a problem.
Does this experience ring any bells with other programmers?
It has been driving me crazy!
I think that I have highlighted a problem with using a hyperlink from one perl programme to another.
I am writing software to update records stored on the server.
I have two programs
add_record.pl which receives a request from a display programme to add a new record.
display.pl which
a) receives information from an add_record.pl program
b) updates the records list, and stores them on the server
c) displays the list of records
A request for a new record is initiated in display.pl by the user mousing over a button and clicking. There is a link to add_record.pl via the hyperlink
<!--- New Item --->
<div style="position:absolute; left:20px; top:220px; width:100px; height:20px;">
<a href="/cgi-bin/addto_quality.pl?UserID=$userid"><img src="/newitem.jpg" width="100" height="20" border="0" alt="New Item"></a>
</div>
newitem.jpg is a pretty little button that I cribbed off Frontpage.
So far so good.
I can update the table easily.
The Question arises how to guard against the user pressing the refresh button, sending the data again and updating a copy of the previous record.
I thought a good solution would be to have a refresh switch stored on the server in a text file. When the program add_record.pl was entered, the refresh switch would be set to 1, by opening the text file for writing, printing the new value, then closing the file
open(TXT, ">refresh.txt");
print TXT "1";
close(TXT);
When the data was sent to the display.pl the program display.pl set the switch to -1 before updating the record. A subsequent call to display.pl via the refresh button would find the refresh switch at -1 and no action would be taken, other then to display the records list.
But this idea only partly works. With the simplest of programmes I can flip back and forth between display.pl and add_record.pl. But when I press Refresh Fn5, the program add_record.pl does not set the refresh parameter to 1. It does not seem to open the file.
After many hours trying to understand the problem, I have solved the problem by abandoning the idea of a GET type hyperlink to perl. Instead I created a custom button via
<!--- New Item --->
<div style="position:absolute; left:20px; top:220px; width:100px; height:20px;">
<form method="post" action="/cgi-bin/add_record.pl" >
<input type="hidden" name="UserID" value="$userid" />
<input type = "image" name = "Send2" value="Send2 alt="Send2" src="/newitem.jpg" />
</form>
</div>
where newitem.jpg is the custom button image.
This now works but I dont know why the other method does not. I have used hyperlinks to perl hundreds of times in other contexts with never a problem.
Does this experience ring any bells with other programmers?
It has been driving me crazy!