Connecting Tech Pros Worldwide Forums | Help | Site Map

submiting a form to a php function

tolkienarda's Avatar
Needs Regular Fix
 
Join Date: Dec 2006
Posts: 316
#1: Jan 16 '07
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_fetch_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($log)
{
$_SESSION['login'] = $log;
$display=1;
}
[/HTML]

thanks in advanced to any help

ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Jan 16 '07

re: submiting a form to a php function


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:
Newbie
 
Join Date: Jan 2007
Location: Netherlands
Posts: 12
#3: Jan 17 '07

re: submiting a form to a php function


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

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

Hope this helped,
Grtz Bertjh
Reply