Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Maputo, Mozambique
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Confirmation box in cgi script

    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
    "COGITO, ERGO SUM"

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Alex,

    Can I suggest that you change the format of your code to read something like:
    Code:
    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.

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Maputo, Mozambique
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for answer. I'll try towork around the solution advised.
    ciao
    Alex
    "COGITO, ERGO SUM"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •