Jump to content

function to php form


Recommended Posts

how can i link a function to a php form so it can run the function on submit


i know you have to add the function in the action="" but is there anything i need add to make this work correctly?

Edited by divinedesigns1
Link to comment
Share on other sites

No, you do not add the function in the action.  If you think you know that, then you're on the wrong path.  The action should be the URL of a PHP file on the server.  If you want to run a particular function in that file, then use a hidden form input or something with a name that you check for, and a value that tells you which function to execute.  You do that the same way you use with any other logic, you can use a series of if statements, or a switch statement, or you can have an array of allowed functions and call it just by passing the name.  e.g.:

$allowed_functions = ['func1', 'func2', 'func3'];
	if (in_array($_POST['function_name'], $allowed_functions)) {

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...