I need help trying to access the name of a form element.
eg. Sample 1: <input name="function1_name" type="text" />
Sample 2: <input name="function2_name" type="text" />
When the form is submitted I will use explode() or someother string function on the input Name (eg function1_name). The resulting string, or string portion, will actually be the name of the function to be called to process that value.
In the above example, the value for the first input would be passed to a procedure called function1 and the value for the second input would be passed to function2. The problem is that I am not sure how to access the names of the form elements in my php scripts.
Make sense?
Thanks
Accessing form element Name
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: Accessing form element Name
if I understand you properly, it's an exceptionally bad idea form a security standpoint
What you might want to look into the the MVC / router concept. A URL maps to a controller action, with extra URL parameters as arguments.
Example:
That way a controller (class) named "contorller" would execute the "action" method with specified arguments. This ensures that you make only the methods you want the user to have access to available to the application interface.
There are plenty of PHP frameworks that use MVC, but it's easy enough to roll your own. Chris Corbyn wrote a nice and simple one somewhere with a great explanation; I think it's on his blog.
What you might want to look into the the MVC / router concept. A URL maps to a controller action, with extra URL parameters as arguments.
Example:
Code: Select all
http://somesite.com/controller/action/a ... 2/val2/....There are plenty of PHP frameworks that use MVC, but it's easy enough to roll your own. Chris Corbyn wrote a nice and simple one somewhere with a great explanation; I think it's on his blog.