<?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>&nbsp;</td></tr>
<tr><td align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
								echo 'Welcome: ' . $_SESSION['username'];
								?>
							<a href="cust_FnB_Login.php"><img src="images/logout3.gif" align="right"></a>	
							</td>
</tr>
<tr><td>
<h2 align="center">NEW CUSTOMER</h2> 
<form  method="post">
<table align="center"  class="imagetable">
 <tr>
   		 <td  align="center">Salutation</td>
    	 <td>:</td>
   		 <td><select class="span3" name="cust_salutation" value="<?php echo htmlentities($_REQUEST['cust_salutation']); ?>">
                                        <option></option>
                                        <option>Mr</option>
										<option>Mrs</option>
                                        <option>Ms</option>
                                    	</select>
  	</tr>
	
	<tr><td>Name</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_name"required></td></tr>
<tr><td>Company</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_company"required></td></tr>
<tr><td>Position</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_position"></td></tr>
<tr><td>Contact</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_contact"></td></tr>
<tr><td>Email</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_email"></td></tr>
<tr><td>Address</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_address1"></td></tr>
<tr><td>&nbsp;</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_address2"></td></tr>
<tr><td>&nbsp;</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_address3"></td></tr>
<tr><td>&nbsp;</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_address4"></td></tr>
<tr><td>Postcode</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_postcode"></td></tr>
<tr><td>City</td><td> : </td><td><input type="text" size="100" maxlength="100" name="cust_city"></td></tr>
<tr>
      <td><label class="control-label" for="input01">State</label></td>
	  <td>:</td>
	  <td>
      <select name="state_name" >
	  <option selected="selected">--Please Select-- </option>
							  <!--option ><!--?php echo  $row['designation_id']; ?></option-->
                                <?php 
							$state=mysql_query("select * from   tbl_ref_state")or die(mysql_error());
							while($row_section=mysql_fetch_array($state)){?>
                                <option>
								<?php echo $row_section['state_name']; ?>
                                <?php } ?>
                                </option>
       </select>
	  </td>

   </tr>  
<!--tr><td>State</td><td> : </td><td><input type="text" size="100" maxlength="100" name="state_name"></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="CUSTOMER LIST" onClick="window.location.href='cust_FnB_view.php'"> 
<!--input type="button" class="myButton" value="ADMINISTRATOR MENU" onClick="window.location.href='administrator_menu.php'"--> </td></tr>

</table>
</form>
<?php
// escape variables for security
if (isset($_POST['save'])){
$cust_salutation = mysql_real_escape_string($_POST['cust_salutation']);
$cust_name = mysql_real_escape_string($_POST['cust_name']);
$cust_company = mysql_real_escape_string($_POST['cust_company']);
$cust_position = mysql_real_escape_string($_POST['cust_position']);
$cust_contact = mysql_real_escape_string($_POST['cust_contact']);
$cust_email = mysql_real_escape_string($_POST['cust_email']);
$cust_address1 = mysql_real_escape_string($_POST['cust_address1']);
$cust_address2 = mysql_real_escape_string($_POST['cust_address2']);
$cust_address3 = mysql_real_escape_string($_POST['cust_address3']);
$cust_address4 = mysql_real_escape_string($_POST['cust_address4']);
$cust_postcode = mysql_real_escape_string($_POST['cust_postcode']);
$cust_city = mysql_real_escape_string($_POST['cust_city']);
$state_name =mysql_real_escape_string($_POST['state_name']);
//$staff_assign = mysql_real_escape_string($_POST['staff_assign']);

// insert record into database
$sql="INSERT INTO tbl_dir_fnb_customer (cust_salutation, cust_name, cust_company, cust_position, cust_contact, cust_email,cust_address1,cust_address2,cust_address3, cust_address4,cust_postcode,cust_city,state_name)
VALUES ('".$cust_salutation."','".$cust_name."', '".$cust_company."', '".$cust_position."', '".$cust_contact."', '".$cust_email."','".$cust_address1."','".$cust_address2."','".$cust_address3."','".$cust_address4."','".$cust_postcode."','".$cust_city."','".$state_name."')";

if (!mysql_query($sql)) {
  die('Error: ' . mysql_error($conn));
} else {
echo "<script> alert('1 record added!');window.location.href='cust_FnB_view.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>
