Hi guys
I keep getting this error know
Notice: Undefined index: group_id in c:\program files\apache group\apache\htdocs\edit_staff.php on line 35
Notice: Undefined index: module_id in c:\program files\apache group\apache\htdocs\edit_staff.php on line 37
both errors marked with a *
what does it mean?
I have got these fields and i thought i have defined them at the end of the code.........
here is my code
<?php
doCSS();
error_reporting(E_ALL);
if(isset($_POST["submit"]))
{
// Info has been submitted, check it:
// Check login, description and description2 are not empty:
{
field_validator("staff_id", $_POST["staff_id"], "alphanumeric", 4, 15);
field_validator("first_name", $_POST["first_name"], "string", 4, 35);
field_validator("last_name", $_POST["last_name"], "string", 3,35);
field_validator("faulty_id", $_POST["faulty_id"], "number", 3,7);
field_validator("date_started", $_POST["date_started"], "string", 8,12 );
*field_validator("group_id", $_POST["group_id"], "number", 1,2);
*field_validator("module_id", $_POST["module_id"], "number", 1,7);
field_validator("module_id2", $_POST["module_id2"], "number", 1,7);
field_validator("module_id3", $_POST["module_id3"], "number", 1,7);
// build query:
$query="SELECT staff_id FROM staff WHERE staff_id='".$_POST["staff_id"]."'";
// Run query:
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if any: ".mysql_error());
// If a row exists with that username, issue an error message:
if( ($row=mysql_fetch_array($result)) )
{
//$messages[]="staff_id\"".$_POST["staff_id"]."\" already exists. Try another.";
}
if(empty($messages))
{
// update db with new info:
//global $link;
$query = "UPDATE `staff` SET `first_name`='{$first_name}',`last_name`='{$last_name}', `faulty_id`='{$faulty_id}' `date_started`='{$date_started}', `group_id`='{$group_id}', `module_id`='{$module_id}',`module_id2`='{$module_id2}', `module_id3`='{$module_id3}' WHERE `staff_id`='{$staff_id}'";
$result=mysql_query($query) or die ("died on updating staff details. error returned if any:" .mysql_error());
//print "staff details modified to system";
}
else
{
displayErrors($messages);
}
}
$query = "select * from staff order by staff_id";
$result = mysql_query($query);
//will work. then to put all the results in textboxes
// Run query:
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if anyzzzz: ".mysql_error());
$data = mysql_fetch_array($result);
print "<center>";
print"<H3>Edit details of staff memeber <H3>";
print"<table>";?>
<form action="<?=$_SERVER["PHP_SELF"]?>" method="POST">
<?
print "<input type=\"text\" name=\"staff_id\" value=\"{$data[0]}\"><br />\n";
echo "</tr>";
echo "<input type=\"text\" name=\"first_name\" value=\"{$data[1]}\"><br />\n";
echo "<input type=\"text\" name=\"last_name\" value=\"{$data[2]}\"><br />\n";
echo "<input type=\"text\" name=\"faulty_id\" value=\"{$data[3]}\"><br />\n";
echo "<input type=\"text\" name=\"date_started\" value=\"{$data[4]}\"><br />\n";
echo "<input type=\"text\" name=\"group_id\" value=\"{$data[5]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id\" value=\"{$data[6]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id2\" value=\"{$data[7]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id3\" value=\"{$data[8]}\"><br />\n"; ?>
<input name="submit" type="submit" value="Submit">
</TABLE>
</center>
</form>