Forum Moderators: coopster
We have a form with 50 input fields. Each input field has it's own name and I could create variables with PHP by hand like this:
<?php
$donationtype = $_POST["donationtype"];
$howardnichols = $_POST["howardnichols"];
$inMemoryofCustom = $_POST["inMemoryofCustom"];
$inMemoryofCustomName = $_POST["inMemoryofCustomName"];
?php>
However in an ideal setting, the variables would be created dynamically with some scripting.
The eventual goal is to pass these variables to a final data review panel that would contain an echo of the current value of said variable and an option to edit that input value via a microlink without having to go back to the original input page.
At this point it would probably be easier in the immediate future to create all of the variables by hand that way I don't have to script a variable driven action when it comes to the "Edit" microlink, but it may work better in the long run for my predecessors.
Any thoughts on if it is necessary and how I would do it would be greatly appreciated.
Right now I'm just echoing the variables I created manually.
<?php
echo "Donation Type ".$donationtype.
echo "<br /> Howard Nichols ".$howardnichols;
echo "<br /> In Memory Of ".$inMemoryofCustom.;
echo "<br /> In Memory Name ".$inMemoryofCustomName;
?php>
Also if you use "standard" global variables like dbname, dbuser, dbpassword, the hacker can override these too to point to their own database, etc. Who knows, hackers will try everything, you'll have to be super careful to make sure your script is secure.
Here are two ways that are a bit more secure:
1) You still need to maintain a list of all these variable names somewhere, so you can figure out the label for each of them, maybe:
$labels = array(
'donationtype' => 'Donation Type',
'howardnichols' => 'Howard Nichols',
...
);
If you have such an array, you could do:
foreach (array_keys($labels) as $field) {
${$field} = $_POST[$field];
}
2) Name all your form fields as array elements, e.g.
<input type="text" name="userdata[donationtype]" ...>
<input type="text" name="userdata[howardnichols]" ...>
And in your script:
$userdata = $_POST['userdata'];
...
echo "Donation Type ".$userdata['donationtype'];
echo "<br /> Howard Nichols ".$userdata['howardnichols'];
...
And again, if there is no interaction with a database within my script/form is it even possible to access the DB (that doesn't exist).
though you aren't going to a db you must be doing something with it or you wouldn't be collecting it
so email? file?
either way all these things can be exploited so test each individually