Jump to content
Sign in to follow this  
divinedesigns1

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

Share this post


Link to post
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)) {
	  {$_POST['function_name']}();
	}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...