<?php
include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }

date_default_timezone_set('Asia/Calcutta');
$today = date("Y-m-d");
$time = date("h:i A"); 
$currentyear = date("Y");
$f_year = $_REQUEST['f_year'];
?>
<?php
if($_REQUEST['unique_id']=='') {
function randomPassword() {
    $alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+%^@!*~";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
    for ($i = 0; $i < 10; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}
$unique_id = randomPassword();
}else { 
$unique_id = $_REQUEST['unique_id'];
}

 $querylogin = "select * from users where username = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
$resultlogin = mysql_query($querylogin,$conn);
while($row=mysql_fetch_array($resultlogin))
{
$Designation = $row['designation'];
$staff_name = $row['full_name'];
$department_name = $row['department_name'];
 $staff_id = $row['id'];


}
?>





<?php
$customer_id=$_REQUEST['customer_id'];

$qry9 = "select * from customer_master where customer_id = '$customer_id'";
$re9 = mysql_query($qry9);
while($row=mysql_fetch_array($re9))
		{  
		$customer_id = $row['customer_id'];
				$id = $row['id'];

		$customer_name = $row['customer_name'];
		}
		

$saul = $_POST['saul'];
$name = $_POST['name'];
$gender = $_POST['gender'];
$bday = $_POST['bday'];
$department = $_POST['department'];
$designation = $_POST['designation'];
$contact_types = $_POST['contact_types'];
$email = $_POST['email'];
$office_phone = $_POST['office_phone'];
$mobile_no = $_POST['mobile_no'];
$linkedinid = $_POST['linkedinid'];
$twitterid = $_POST['twitterid'];
$remark = $_POST['remark'];

$qry3 = "insert into contact_person(id,customer_id,saul,name,gender,bday,department,designation,contact_types,email,office_phone,mobile_no,linkedinid,twitterid,remark,customer_name) values ('$id','$customer_id','$saul','$name','gender','$bday','$department','$designation','$contact_types','$email','$office_phone','$mobile_no','$linkedinid','$twitterid','$remark','$customer_name')";
$r3=mysql_query($qry3,$conn);
?>


<script>
javascript:window.location.href="view_all_contacts.php";
</script>
