By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,746 Members | 1,849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,746 IT Pros & Developers. It's quick & easy.

submiting a form to a php function

tolkienarda
100+
P: 316
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
Jan 16 '07 #1
Share this Question
Share on Google+
2 Replies


ronverdonk
Expert 2.5K+
P: 4,258
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:
Jan 16 '07 #2

P: 12
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
Jan 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.