PDA

View Full Version : Confirmation box in cgi script


Alex Piotto
09-17-2002, 04:13 PM
Hi people!
This is my first post in the cgi forum...
I use to work with PHP, but I really need to finish an old perl job.

I have a script that receive the action command from a previous page/script and then delete data in a simple db.

I need to add a confirmation box to warning the users they are actually deleting an item... how can I do this?

I am trying to insert some javascript inside the cgi code, but it is not working... :(

Here is the part of the code where I need the confimation box
______________________________________
if ($input{'action'} eq 'delete'){

//confirm: delete or not? If not, go back, if yes, do the following:

open (DATABASE,">$database");
@DB=<DATABASE>;
foreach $rec (@ODB){
chomp($rec);
($titulo,$itemtime,$texto,$obs)=split(/\|/,$rec);

if ($titulo eq $input{'titulo'} && $itemtime eq $input{'itemtime'} && $texto eq $input{'texto'} && $obs eq $input{'obs'}){
print DATABASE "";
}else{
print DATABASE "$titulo|$itemtime|$texto|$obs\n";
}
}
close (DATABASE);
}
_______________________________________

Any help will be very very very very welcome!

Alex :)

fivesidecube
09-18-2002, 08:58 AM
Alex,

Can I suggest that you change the format of your code to read something like:if ($input{'action'} eq 'delete'){
// Output HTML confirmation page, using a second form and
// hidden fields to store required information from the
// initial form.
}
else if ($input{'action'} eq 'confirmed'){
open (DATABASE,">$database");
...
}The basis behind this is to replace the original HTML form with a confirmation form that calls the same script, with all the same parameters, although hidden the second time around. The only difference is that the submit of the confirmation screen changes the value of the $input{'action'} scalar value to 'confirmed', thus enabling the script to actually delete the DB item.

Hope this helps.

Alex Piotto
09-18-2002, 11:43 AM
Thanks for answer. I'll try towork around the solution advised.
ciao
Alex
:)