 |
|
Code (PHP)
<?
session_start();
include "connect.php";
$name = $_POST['name'];
$position1 = $_POST['position'];//
$branch = $_SESSION["BranchID"];//
$branch1 = $_POST['branch'];//
$gender = $_POST['Gender'];//
$IDCard = $_POST['IDCard'];//
$telephone = $_POST['Telephone'];//
$email = $_POST['email'];//
$address = $_POST['Address'];//
$TranferDate = $_POST['TranferDate'];
$TranferDate2 = $_POST['TranferDate2'];
$status = $_POST['status'];//
$username1 = $_POST['username'];
$password1 = $_POST['password'];
list( $day, $month, $year) = explode('-',$TranferDate); //Çѹ·ÕèàÃÔèÁ·Ó§Ò¹
$StartDate=$year."-".$month."-".$day;
list( $day, $month, $year) = explode('-',$TranferDate2); //ÅÒÍÍ¡
$endDate=$year."-".$month."-".$day;
if($status == "1") //·Ó§Ò¹
$status = "1";
else
$status = "2"; //ÅÒÍÍ¡
if($gender == "M") //à¾È
$gender = "M";
else
$gender = "F";
if($_SESSION["BranchID"]!=0){
$sqlQuery = "INSERT INTO employees (EmpName,PositionID,BranchID,Gender,IDCard,Telephone,Email,Address,StartDate,EndDate,Status,Username,Password) VALUES ('$name','$position1','$branch','$gender','$IDCard','$telephone','$email','$address','$StartDate','0000-00-00','$status','$username1','$password1')";
$result = mysql_query($sqlQuery) or die('Query failed: ' . mysql_error());
$showall=0;
}
else{//insert by admin
$sqlQuery = "INSERT INTO employees (EmpName,PositionID,BranchID,Gender,IDCard,Telephone,Email,Address,StartDate,EndDate,Status,Username,Password) VALUES ('$name','$position1','$branch1','$gender','$IDCard','$telephone','$email','$address','$StartDate','0000-00-00','$status','$username1','$password1')";
$result = mysql_query($sqlQuery) or die('Query failed: ' . mysql_error());
$showall=1; }
?>
<script type="text/javascript">
alert("บันทึกข็อมูลเรียบร้อยเเล้ว")
window.location = "employee.php?showall=<?=$showall;?>"
</script>
Tag : PHP, MySQL, Ms SQL Server 2005, Ms SQL Server 2008, JavaScript, jQuery

|
|
 |
 |
 |
 |
Date :
2012-01-18 19:10:56 |
By :
BNforever |
View :
1004 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |