I have an html form, with 13 <input> fields and approx. 92 different rows, created using php which pulls the records from a mySQL database. For some reason when I have a name assigned to this one field, it causes my <input type="submit" name="update_submit"> button not to set. If I change the name, it doesn't matter, but if I remove the name it will allow the other fields to update just fine.
Here is a snippet of my form code( $i is auto incremented):
Up Top...
<form method="post" action="process_form.php">
<table>
<tr>
Further down...
echo "<td align=\"center\" class=\"edit_emp_comp_exp_cell\"><input type=\"text\" maxlength=\"10\" size=\"10\" id=\"Lic_Comp_Exp$i\" name=\"Lic_Comp_Exp[]\" value=\"" . $emp_query['Lic_Comp_Exp'] . "\">";
<input type="submit" name="update_submit" style="width:100px;" value="UPDATE">
Further down...
</tr>
</table>
</form>
Here is my process_form:
if(isset($_POST['update_submit']))
{
$id = $_POST['Emp_ID'];
$name = $_POST['Emp_Name'];
$phone = $_POST['Emp_Phone'];
$start = $_POST['Start_Date'];
$leave = $_POST['Paid_Leave'];
$aca = $_POST['Emp_ACA'];
$licauth = $_POST['Lic_Auth_ID'];
$authexp = $_POST['Lic_Auth_Exp'];
$liccomp = $_POST['Lic_Comp_ID'];
$compexp = $_POST['Lic_Comp_Exp'];
$miscp = $_POST['MiscP_ID'];
$position = $_POST['Pos_ID'];
$active = $_POST['activeBox'];
$i = 0;
foreach($id as $update)
{
if (!isset($active[$i])) { $active[$i] = 0; }
$sql = ("UPDATE employee SET Emp_Name = '$name[$i]', Emp_Phone = '$phone[$i]', Emp_Start_Date = '$start[$i]', Paid_Leave = '$leave[$i]', Emp_ACA = '$aca[$i]', Lic_Auth_ID = '$licauth[$i]', Lic_Auth_Exp = '$authexp[$i]', Lic_Comp_ID = '$liccomp[$i]', Lic_Comp_Exp = '$compexp[$i]', MiscP_ID = '$miscp[$i]', Pos_ID = '$position[$i]', Emp_Active = '$active[$i]' WHERE Emp_ID = '$update'");
echo "SQL: " . $sql . "<br>";
if(!$result_employee_update = $mysqli->query($sql))
{
$errors[] = "There was an error updating the employee table. MySqli Error Number: " . $mysqli->errno . "";
goto end;
}
$i++;
}
goto redirect;
}
I am at a total loss and have been troubleshooting this all morning, I would really appreciate some help.
UPDATE: When I change if(isset($_POST['update_submit'])) to if(!isset($_POST['update_submit'])) and run it, I get an error:
"Notice: Undefined offset: 83 ... on line 31"
and line 31 is my
`$sql = ("UPDATE employee SET Emp_Name = '$name[$i]', Emp_Phone = '$phone[$i]', Emp_Start_Date = '$start[$i]', Paid_Leave = '$leave[$i]', Emp_ACA = '$aca[$i]', Lic_Auth_ID = '$licauth[$i]', Lic_Auth_Exp = '$authexp[$i]', Lic_Comp_ID = '$liccomp[$i]', Lic_Comp_Exp = '$compexp[$i]', MiscP_ID = '$miscp[$i]', Pos_ID = '$position[$i]', Emp_Active = '$active[$i]' WHERE Emp_ID = '$update'");`
I think that means that one of my <input> is not an array, right? If that is so, I don't know how that can be, the table is there and its created dynamically from the database.
UPDATE2: I think I've got something figured out, but I don't know how to fix it. I tried leaving the name="Lic_Auth_Exp" and name="Lic_Comp_Exp" and then removing two different name attributes from other input fields. After doing that it seemed to run the code. So the problem isn't because of these specific fields, but it seems to be because of there being more than 11 $_POST values being passed. I looked through the php.ini file to see if there were any limits on such a thing, but I didn't see anything. Does anyone know what could be causing this??