I have a following html markup (it's a basic structure to let you know, as some people will ask me where is the tag. Consider it being there.)
<input type="text" name="set_val_1" id="set_val_1" value="1"/>
<input type="text" name="set_val_2" id="set_val_2" value="2"/>
<input type="text" name="max_risk_id" id="max_risk_id" value="5"/>
<input type="submit" value="Enter" name="submit_button"/>
Now when the form will be submitted I want to have a code to detect whether any POST appeared in the format "set_val_
". I hope I can make you understand what I am actually asking.
An algorithm based on my issue:
if(isset($_POST['something with the pattern (set_val_)']))
{
$flag = 1;
$val_string = "";
}
if($flag == 1)
{
$max_id = $_POST['max_risk_id'];
for($i = 1; $i<=$max_id; $i++)
{
if(isset($_POST['set_val_'.$i]))
{
$val_string = $val_string. $_POST['set_val_'.$i].",";
}
}
}
How can I check whether a post occurred of a particular name format?