Well, do some. dumps to check where it goes wrong, maybe the page doesn’t. exist or you don’t get the right data from your post, without knowing what exactly. you are posting etc., it’s a. bit hard and you have to figure it out.
What is that line doing there? I think I wrote before that the children() method doesn’t accept a parameter.
And this line:
if($data) $error = 'Something is invalid.';
doesn’t seem to make sense, either… What do you want to achieve here? In your comment says you validate the data, but in fact you fill the error variable if $data is true, hm…
Also, if you want to validate your data, you should do that before you use the data, not after. for example, check if days is numeric and in the range of allowed values, and check if the value for country is in the array of allowed countries. Anyone can easily modify the data that is sent to the. server.
And one more thing: If you want to get the average arrival time, it doesn’t make sense to add the values up. You would have to calculate an average…
If you store the data in those subpages anyway, you might as well retrieve it from there instead of also updating the main page itself.
But it would be better to only update the page with the new information without creating all those subpages that just clatter the folder for nothing. For example, you use a new counter field for the number of submissions (I,e, increase by 1 for each new submission, and you add up the days in the days field. Then you can easily display your average in the template.