Results 1 to 3 of 3

Thread: how to tell from which button send to the script?

  1. #1
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to tell from which button send to the script?

    hi All
    I have three input type button which do some function.
    If I press "save" or "del" button, they post data to the remote machine's php script.
    How can my php script tell from which button send to it?

    <form action="b01svr.php" OnSubmit="return isEmpty(this)" method="POST">
    .......................
    <tr><td><input type="reset" value="clear"></td></tr>
    <tr><td><input type="submit" value="save"></td></tr>
    <tr><td><input type="submit" value="del"></td></tr>
    </form>

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    While creating the submit button make sure that you give each button a unique name like the following
    Code:
    <input type="submit" name="save" value="Save">
    <input type="submit" value="Del" name="del">
    In your PHP page you can just have code like the following

    Code:
    $save = $_POST['save'];
    $del = $_POST['del'];
    If you put the above code in your PHP code you can find out which button has been pressed by the user.

    If the user clicked save button then you'll get the value you've mentioned in the value attribute of save <input> tag in this case it is Save.

    If the user clicked del button then you'll get the value you've mentioned in the value attribute of del <input> tag in this case it is Del.

    I think the technique is clear now so based on the value stored in the $save and $del you can identify the button press.

  3. #3
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks codeexploiter
    I got the way to send and receive data between client and server.
    Thanks.

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
  •