Page 1 of 1

PHP function as form action: possible?

Posted: Tue Apr 06, 2004 4:32 pm
by ~fleece~
Is it possible to do something like:

<form action="some php function" method="post">

and if not how can I make a form call a PHP function in some other way?

Thanks :)

Posted: Tue Apr 06, 2004 4:36 pm
by markl999
You can't (like that) as PHP is server side so you'de have to send another request to the server. So you could do something like <form action="foo.php?func=somefunc" action="post">

Then in foo.php ...
if(!empty($_GET['func']) && function_exists($_GET['func'])){
$_GET['func']();
}

or put the func in a hidden form field and use $_POST['func'] but be sure to check for functions you only want to allow, i.e don't allow exec() etc..