<?php  include("conn/conn.php");
if($Submit=="提交"){
   	if(preg_match("/^(\d{11})$/",$colleague_tel,$counts)){ 
		if(preg_match("/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/",$colleague_mail,$counts)){   
			$sqlstr = 'select * from tb_colleague where tb_colleague_id = 0';		//生成sql语句
			/*执行SQL语句 */
			$rst = $conn -> execute($sqlstr) or die('Error: '.$conn -> errorMsg()) ;
			$fields = array();										//创建一个数组
			$fields['tb_colleague_name'] = $_POST['colleague_name'];						//想数组中添加数据
			$fields['tb_colleague_tel'] = $_POST['colleague_tel'];						//想数组中添加数据
			$fields['tb_colleague_mail'] = $_POST['colleague_mail'];						//想数组中添加数据
			$fields['tb_colleague_birthday'] = $_POST['colleague_birthday'];						//想数组中添加数据
			$fields['tb_colleague_address'] = $_POST['colleague_address'];						//想数组中添加数据
			$fields['tb_colleague_category'] = $_POST['colleague_category'];						//想数组中添加数据
			/*添加新数据*/
			$insert = $conn -> getInsertSQL($rst,$fields) or die('update error：'.$conn -> errorMsg());
			$conn -> execute($insert);								//执行添加
			echo "<script>alert('联系人信息添加成功！');history.back();</script>";

 		}else{
         echo "<script>alert('您输入的邮箱地址的格式不正确!!');history.back()</script>";

		}
	}else{
         echo "<script>alert('您输入的电话号码的格式不正确!!');history.back()</script>";
	}
}
?>