Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

HTML & PHP Question

  • 24-05-2006 10:08PM
    #1
    Registered Users, Registered Users 2 Posts: 148 ✭✭


    Hi,

    I have a problem on ,y page where I have two input bottons, one for Update and one for Delete. I need to set a flag, U for update and D for delete.

    What I ahve done so far in my Update botton my setting is this

    <input name="update" type="submit" values="update" onclick="<?php $_SESSION = 'U'; ?>"

    While my delete botton;

    <input name="delete" type="submit" values="delete" onclick="<?php $_SESSION = 'D'; ?>"

    Whenever I press update botton still giving me a flag of D, is this possible ? or is there any othe way to do it ?

    Please help and thanks . . . .


Comments

  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    You're mixing up twoish things here ...

    Server Side and Client Side ...


  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    thanks, still new to this, so this is not possible then ... is there other way to set the flag ?


  • Registered Users, Registered Users 2 Posts: 2,203 ✭✭✭Serbian


    You need to do something like this:

    [php]<?php

    if ( $_SERVER == 'POST' ) {

    $submit = $_POST;

    if ( $submit == 'Update' ) {
    print 'You clicked Update.';
    }
    else if ( $submit == 'Delete' ) {
    print 'You clicked Delete';
    }

    }
    ?>
    <form method="post" action="<?php print $_SERVER; ?>">
    <input type="submit" name="submit" value="Update" />
    <input type="submit" name="submit" value="Delete" />
    </form>[/php]


  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    Remove the javascript from the html.
    Change the values attribute to value on each submit button.
    In the php script handling the form submission, retrieve the value from each button with something like
    $update = $_POST;
    $delete = $_POST;
    and use a switch command to handle as appropriate.

    Edit: Or as Serbian posted! (beat me to it)


  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    sorry for the lack of a solution in my response last night ... was busy .. but you've got other responses in the meantime that look good


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    Guys, thank you very much, I will try that tonight, let you know the outcome.


  • Closed Accounts Posts: 850 ✭✭✭DOLEMAN


    If you're new to PHP I highly recommend this book -

    http://www.amazon.com/gp/product/0672326728/sr=8-1/qid=1148676981/ref=pd_bbs_1/103-1920949-5241460?%5Fencoding=UTF8

    It'll bring you up to speed in no time.


Advertisement