SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 submit buttons into 1

    Hello,

    By using one of my scripts, i can delete as well as update the fields.I'm using this one using two submit buttons, Update and delete.

    Update is very simple: The user make some changes and click update and is updated.

    Delete is done in two steps:At the end of each record, there is a check box placed and when the user checks this box and hit delete, it asks for confirmation.

    This is also fine!!

    Now, instead of two submit buttons, i want to use only one, i.e submit.

    How can i modify my piece of code??
    Could somebody pls help me out.

    Thanks in advance!

    PHP Code:
    <?php
         
         
    // Delete (btn_delete)
        
    if (isset($HTTP_POST_VARS["btn_delete"]))
        {
        
    $delete $HTTP_POST_VARS["delete"];
        if (
    is_array($delete) && !empty($delete))
           {
        
    reset($delete);
        while (list(
    $key,$id) = each($delete))
             {
        
    $sql "UPDATE TBL_RBS SET RBS_DELETE = 1 
                where RBS_ID = 
    $id";
        
    $result ibase_query($sql);
             }
        
    $delete_serialized urlencode(serialize($delete));
        echo 
    "
        <center>
        <B>Chosen records marked for removal!</B><BR>\n
        <B>Do you really want to remove them? </B><BR>\n
        <form name=\"formConfirm\" method=\"post\" action=\"\">
        <input type=\"hidden\" name=\"delete\" value=\"
    $delete_serialized\">
        <input type=\"submit\" name=\"btn_del_confirmed\" value=\"Delete!\">&nbsp;&nbsp;
        <input type=\"submit\" name=\"btn_del_cancel\" value=\"Restore!\"><BR>\n
        </form>
        </center>
        "
    ;
        exit;
           }
        }
    // Delete confirmed (btn_del_confirmed)
        
    else if (isset($HTTP_POST_VARS["btn_del_confirmed"]))
        {
        
    $update $HTTP_POST_VARS["update"];
        
    $delete unserialize(urldecode($delete));
        
    reset($delete);
        if (
    is_array($delete) && !empty($delete))
           {
        
    reset($delete);
        while (list(
    $key,$id) = each($delete))
             {
        
    $sql "DELETE from TBL_RBS where RBS_ID = $id";
        
    $result ibase_query($sql);
             }
           }
        }
    // Delete cancelled (btn_del_cancel)
        
    else if (isset($HTTP_POST_VARS["btn_del_cancel"]))
        {
        
    $delete $HTTP_POST_VARS["delete"];
        
    $delete unserialize(urldecode($delete));
        
    reset($delete);
        if (
    is_array($delete) && !empty($delete))
           {
        
    reset($delete);
        while (list(
    $key,$id) = each($delete))
             {
        
    $sql "update TBL_RBS SET RBS_DELETE = 0 where RBS_ID = $id";
        
    $result ibase_query($sql);
             }
           }
        }
    // Update (btn_update)
        
    else if (isset($HTTP_POST_VARS["btn_update"]))
        {
        
    reset($data);
        while (list(
    $id$rbs_data) = each($data))
           {
    //sql update Statement
           
    }
        }

    //sql select statement    
        
    ?>
    Field headings are here

    <?php
    //While statement to fetch the records

    ?>
    All form fields are placed here!!

    <?php

    }
    ?>
    </table>

    <Input type="submit" name="btn_update" value="Update">
    &nbsp;&nbsp;
    <input type="submit" name="btn_delete" value="Delete">
    &nbsp;&nbsp;
    </form>
    </body>
    </html>

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    itz fixed *No MESG*

    itz fixed *No MESG*


Bookmarks

Posting Permissions

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