<?php session_start();?>
<?php require_once('open_connection.php');?>
<!--link href='blue/style.css' rel='stylesheet' type='text/css' /-->
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />
<!DOCTYPE html>
<html>
<head>
       <title>PICCSB e-Directory System</title>
</head>
<body bgcolor="#333333"> 
<table width="100%" border="0" align="center">
<tr>
<td width="15%" bgcolor="#333333">&nbsp;</td>
<td width="70%" align="center" bgcolor="#FFFFFF" > 

<table width="100%" border="0" align="center">

<!-- row for header picc 1 -->
<tr>  
     <th width="100%" colspan="4"><img src="images/header-cox.jpg" width="100%" height="30%"></th>
</tr>

<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%" height="15%"></th>
</tr>

<!-- calling frame -->	
<tr>
    <td colspan="1" width="10%" align="center"><?php include("header.php");?></td>
	
</tr>
<tr>

<td colspan="3" width="90%" align="center" >

<tr><td align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
								echo 'Welcome: ' . $_SESSION['username'];
								?>
							<a href="staff_logout.php"><img src="images/logout3.gif" align="right"></a>
							</td>
</tr>
<tr><td>
<h2 align="center">INSERT STAFF RECORD</h2>
<form  method="post">
<table align="center"  class="imagetable">
<tr><td>Staff Name</td><td> : </td><td><input type="text" size="100" maxlength="100" name="staff_name"required></td></tr>
<tr><td>Section</td><td> : </td><td><select name="staff_section" id="staff_section" class="input-xlarge"required>
                                   <option selected="selected">--Please Select-- </option>
                                   
                            <?php
                                $section_query=mysql_query("select * from tbl_ref_section order by section_name")or die(mysql_error());
                                while($row=mysql_fetch_array($section_query)){
                            ?>
                            <option>
                                 <?php
                                     echo $row['section_name'];
									
                                 ?>
                            </option>
                            <?php
                                }
                            ?>
                            </select></td></tr>
<tr><td>Designation</td><td> : </td><td><select  id="staff_designation" class="input-xlarge" name="staff_designation"required>
                                   <option selected="selected">--Please Select-- </option>
                                   
                            <?php
                                $designation_query=mysql_query("select * from tbl_ref_designation order by designation_name")or die(mysql_error());
                                while($row=mysql_fetch_array($designation_query)){
                            ?>
                            <option>
                                 <?php
                                     echo $row['designation_name'];
									
                                 ?>
                            </option>
                            <?php
                                }
                            ?>
                            </select></td></tr>


<tr><td>Extension</td><td> : </td><td><input type="text" size="11" maxlength="11" name="staff_ext"></td></tr>
<tr><td>H/Phone</td><td> : </td><td><input type="text" size="20" maxlength="20" name="staff_hp"></td></tr>
<tr><td>Email</td><td> : </td><td><input type="text" size="20" maxlength="20" name="staff_emel"required><label>@picc.com</label></td></tr>
<!--<tr><td>Assign Name</td><td> : </td><td><input type="text" size="20" maxlength="20" name="staff_assign"></td></tr>-->
<tr><td colspan="3" align="center"><input type="submit" value="INSERT" name="save" id="save" class="myButton">
<input type="button" class="myButton" value="STAFF LIST" onClick="window.location.href='staff_admin.php'"></td></tr>

</table>
</form>
<?php
// escape variables for security
if (isset($_POST['save'])){
$staff_name = mysql_real_escape_string($_POST['staff_name']);
$staff_section = mysql_real_escape_string($_POST['staff_section']);
//$staff_section_id = mysql_real_escape_string($_POST['staff_section_id']);
$staff_designation = mysql_real_escape_string($_POST['staff_designation']);
$staff_ext = mysql_real_escape_string($_POST['staff_ext']);
$staff_hp = mysql_real_escape_string($_POST['staff_hp']);
$staff_emel = mysql_real_escape_string($_POST['staff_emel']);
//$staff_assign = mysql_real_escape_string($_POST['staff_assign']);

// insert record into database
$sql="INSERT INTO tbl_dir_staff (staff_name, staff_section, staff_designation, staff_ext, staff_hp, staff_emel)
VALUES ('".$staff_name."', '".$staff_section."', '".$staff_designation."', '".$staff_ext."', '".$staff_hp."', '".$staff_emel."')";

if (!mysql_query($sql)) {
  die('Error: ' . mysql_error($conn));
} else {
echo "<script> alert('1 record added!');window.location.href='staff_admin.php';</script>";
}
}

mysql_close($conn);
?>
<!-- row for footer -->	
<tr>
	<th align="center" colspan="4">
	<?php include ('footer.php'); ?>
		
	</th>
</tr>

<!--- end for ruang kerja 80% -->
</table>

</td>

<td width="15%" bgcolor="#333333">&nbsp;</td>

</tr>

<!--- end for ruang kerja 100% -->
</table>

</body>
</html>