All,
I am attempting to create a small site using php/mysql. What I want to do is present a series of links to the user and do a submit using onclick, subsequently passing a variable to the page in the action field of my form declaration.
I have attempted to do this but I am getting undefined index when I try to use $_POST to get to the variable.
My code from the main page:
printf("<form method='POST' name='form1' action='timeselection.php'><input type='hidden' name='StartYear' value='{$line['Environment_Description']}'/><a href='timeselection.php' onclick='document.form1.submit();'>{$line['Environment_Description']}</a></form>");
From timeselection.php :
echo $_POST['StartYear'];
Clicking on the link does not appear to be submitting the form and I'm not sure why. When I do, I get this error :
Notice: Undefined index: StartYear in C:\Apache2\wwwroot\TimeSelection.php on line 11
I know it's not a matter of the variable being unset because even if I set a manual value, I still get the undefined index error.
what am I doing wrong?