simple question !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yaz

    simple question !

    I'm a newbie, and struggling a bit ! I've spent about 3 days trying to
    solve a simple problem, and I've failed.

    I have a screen, with two buttons.
    When the user hits either button, a php function (or procedure) should
    get called, and the php code needs to programatically work out which
    button is pressed. Sounds simple. But I just don't know how to do it. I
    have looked at manuals etc, and tried various things, but I just cant
    find out the construct

    If someone could post a tiny code sample, would be fantasic and much
    appreciated.

    cheers

  • Mark ??;-\)

    #2
    Re: simple question !

    > If someone could post a tiny code sample, would be fantasic and much[color=blue]
    > appreciated.[/color]

    I'm still pretty much learning myself, but this is one way. Let me know if
    this helps.

    -Mark

    <?php
    $content = "<form name='form1' method='post' action=''>
    <input type='submit' name='submit1' value='Submit'>
    </form>
    <form name='form2' method='post' action=''>
    <input type='submit' name='submit2' value='Submit'>
    </form>";
    print $content;
    if (isset($_POST['submit1'])) { //First submit button clicked
    print "The first button was clicked";
    }
    elseif (isset($_POST['submit2'])) { //Second submit button clicked
    print "The second button was clicked";
    }

    //print_r($_POST) ; //Used for Debugging
    ?>



    Comment

    • Ian B

      #3
      Re: simple question !

      The two buttons don't have to be in different forms

      Comment

      • Yaz

        #4
        Re: simple question !

        Mark

        Your example is great, just what I need. Cheers for your help

        Yaz

        Comment

        Working...