submiting a form to a php function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tolkienarda
    Contributor
    • Dec 2006
    • 316

    submiting a form to a php function

    hi i am trying to call a php function called "select". so far i have
    [HTML]<form action="select" method="post">[/HTML]
    the function is in the head of the html document.
    here is the entirety of the form.

    I will need to submit this same form to several different functions throughout the page so that is why i use the method i chose
    [HTML]
    <form method="post" action=<? echo '"', $func, '"'; ?>>
    <select>
    <option>asdf</option>


    <?
    ////////////////////////////////////////////
    //this section will allow a teacher to
    //choose whcih student they would
    //like to edit the settings for at this
    //time it will be the only visible
    //input on the screen.
    ////////////////////////////////////////////
    $i=1;

    while ($i<=$row)
    {
    $row2=mysql_fet ch_row($result) ;
    echo '<option value="', $row2[1], '">', $row2[2], '</option>';
    $i++;
    }
    $func="select";
    ?>
    </select>
    <input type="submit">
    </form>
    [/HTML]

    and the function i am sending it to

    [HTML]
    function selectclass($lo g)
    {
    $_SESSION['login'] = $log;
    $display=1;
    }
    [/HTML]

    thanks in advanced to any help
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    The submit POST does not xfer your form to a function, but to a program script. So when you submit to 'select' it will pass the form to a program of which you defined the name as 'select'. Since that does not exist you'll get a 404 error.

    So you just pass the form to a program, that program could contain the function you want to execute.

    If this is not clear, don't hesitate to come back.

    Ronald :cool:

    Comment

    • BeRtjh
      New Member
      • Jan 2007
      • 12

      #3
      When you post a form, it will be sent to a webpage,.. so the script should be like:

      [HTML]
      <FORM ACTION="mycontr oller.php"> //could be current page with #
      <INPUT TYPE="text" NAME="value" />
      </FORM>
      [/HTML]

      Hope this helped,
      Grtz Bertjh

      Comment

      Working...