President Obama Posted January 13, 2011 Share Posted January 13, 2011 Is it possible to link action in the form to a function thats included from a functions file? Like so: <form action="<?php add($text); ?>" > <input type="text" name="text" /> <input type="submit" /> </form> What I want to do is add a block of text to the database. The add function does that. So ideas? I have like 9 of these forms on the same page they all do different things though but all involve modify the database. Quote Link to comment https://forums.phpfreaks.com/topic/224314-submit-form-to-php-function/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2011 Share Posted January 13, 2011 The action="" attribute is the URL that the form data will be submitted to. Forms only exist in the browser/client and the only thing the client can do is make HTTP/HTTPS requests to the server. You cannot 'call' php functions from the browser. You would need to specify, either by using completely different URLs/pages for each different operation, a GET parameter on the end of one URL, or using a hidden form field value what you want the php code to do when the form is submitted to whatever URL you put into the action="" attribute. Quote Link to comment https://forums.phpfreaks.com/topic/224314-submit-form-to-php-function/#findComment-1158901 Share on other sites More sharing options...
President Obama Posted January 13, 2011 Author Share Posted January 13, 2011 So could I say, put a hidden value on each form, then have the action go to another page which then checks that value and assigns the appropriate function to that form? Quote Link to comment https://forums.phpfreaks.com/topic/224314-submit-form-to-php-function/#findComment-1158926 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.