• PHP – How to Summon a function using buttons

    LowellFeierabend Member

    I’ve a bit of a problem with PHP and the interwebs is full of contradicting information.
    Basicly, I want to summon a function that uses the values using a htmlbutton. I’ve found that you can have your server listening to a form with some buttons in it, but it still won’t work…
    Here’s my function:

    function FillOutArray()
    {
    if(isset($_POST['submit']))
    {
    $array[counter] = $_POST['random'];
    $counter+=1;
    }
    else // resetting array
    {
    $counter = 0;
    $array = array();
    }
    }
    

    and here’s my form:

     

  • SapnaVishwas Member

    ou put that php code as a function but you never actually call that function. Unless there is more code you didn’t post here. Try this:

    if(isset($_POST['submit']))
    {
    $array[counter] = $_POST['random'];
    $counter+=1;
    }
    else // resetting array
    {
    $counter = 0;
    $array = array();
    }
    

    And make sure you clean anything that comes from user input. Although I have no clue what you will do with the data from the input, but it`s best to get the habit of closing security issues right away.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.