I've created an
file where I have several insert functions. My forms are on different pages and some use
and others use
methods, but they all point to the
This was all coded in PHP5.2 and I didn't have much trouble specifying which insert function to execute based on which form is being submitted. However, in my attempts to upgrade to procedural PHP7, I find that my submitted form doesn't necessarily point to the correct insert function in the
Here is an example of how I am doing this:
<form action='insert.php' method='post'>
<input type='hidden' name='form' value='data1'>
//perform insert into db
I have different insert functions with different
variables. Some of these functions are called from forms that use the
method, so I have
- Why are some of my forms not pointing to the correct insert function?
- Is it better to put the
insert functions in different files, or is it okay to leave them in one file?
- I'm thinking of possibly using the below code to solve question 2.
Any thoughts on this solution?
$form = ($_SERVER['REQUEST_METHOD'] == 'GET') ? $_GET['form'] : $_POST['form'];