Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

HTML & PHP Question

Options
  • 24-05-2006 10:08pm
    #1
    Registered Users 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 Posts: 3,594 ✭✭✭forbairt


    You're mixing up twoish things here ...

    Server Side and Client Side ...


  • Registered Users Posts: 148 ✭✭maco


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


  • Registered Users Posts: 2,157 ✭✭✭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 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 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