lundi 30 mars 2015

Getting the right form from a button click

Overview of what my question is:


I have an array that is populated via XML inputs, and from this I am the using it to populate a web form with form controls. From here I want to be able to select the exact form that is clicked, but to do that I need to give the controls some form of unique identifier, which is an issue...


As the site is of a betting nature and I am currently working with horse racing, each horse is given a unique identifier by default, I have tried to add this identifier to the forms. e.g:



<?php
//Values from feed examples: 123, 234, 345
$valuesFromFeed = array(123, 234, 345); //These are not in my code, they are values from the XML feed

while ($uniqueIdentifier = $valueFromFeed) {
<input type="hidden" name="horse_<?php echo $uniqueIdentifier; ?>" />
}
?>


But then the problem comes when I try to reference this name of "horse_123", I need to know exactly what the value of that name is, which is impossible as there are millions of horses, tracks and races.

Example of trying to get post:



<?php
if (isset($_POST['horse_' . $uniqueIdetifier])) {
echo "You got the right thing here.";
} else {
echo "Still no joy.";
}
?>


So to conclude, my point and question:



  • How do I get the correct name from the form in a submit for the specific horse that I wish to reference and get information on?

  • How do I use this information as I need to?


Aucun commentaire:

Enregistrer un commentaire