 |
|
คือผมส่งค่าฟอร์มผ่านะครับ บันทึกได้ แต่แค่มันไม่ redirect หน้าที่หน้าโชว์เฉย ลองหมดทุกทางแล้วครับ
ส่วนี้โค้ดที่สำหรับบันทึกฐานข้อมูลครับ
Code (PHP)
<?php if(isset($_GET['mode']) and $_GET['mode']=='addemp'){
$picname=$_FILES['filepic']['name'];
$pictmp=$_FILES['filepic']['tmp_name'];
///////////////////////////////////////////////////////
$sqlinsert = "insert into tblemployee (emname_thai,emname_eng,emnic_name,ememail,
emphone,emdate_start,emheight,emweight,emid_number,emadd,emcontact,emability_com,
emability,emcomment,emmodel,emlighting_materiel,emend,emnote,emsalary,embirthday,emid,emsex,emiamge)
values('".$_POST['txtnamethai']."','".$_POST['txtnameeng']."','".$_POST['txtnickname']."','".$_POST['txtemail']."',
'".$_POST['txtphone']."','".showdate($_POST['txtdatebegin'])."','".$_POST['txthight']."','".$_POST['txtweight']."',
'".$_POST['txtidcard']."','".$_POST['textarea']."','".$_POST['txtcontact']."','".$_POST['txtskillcom']."',
'".$_POST['txtskillother']."','".$_POST['txtcomment']."',".$_POST['lvmo'].",".$_POST['lvm'].",".$_POST['lvfin'].",
'".$_POST['txtnote']."',".$_POST['txtsalary'].",'".showdate($_POST['txtbirthdate'])."','".$_POST['txteid']."','".$_POST['sex']."','$picname')";
//Add Username Password
$sqlinsertuser = "insert into tbllogin (lnuser,lnpassword,emid) values ('".$_POST['txtusername']."','".$_POST['txtpassword']."','".$_POST['txteid']."')";
//echo $sqlinsert;
if(mysql_query($sqlinsert) && mysql_query($sqlinsertuser) && move_uploaded_file($pictmp,'pic_upload/'.$picname))
{
?><script language="javascript" type="text/javascript">alert("บันทึกข้อมูลพนักงานเรียบร้อย");</script><?php
///Add LogFile
$date = date("Y-m-d");
$time = date("H:i:s");
$sql_logfile = "insert into tblogfile (faction,fdate,ftime) values ('Add Employee ID ".$_POST['txteid']."','$date','$time')";
if (mysql_query($sql_logfile))
{
?><script>alert("testsavelogfile"); document.location = 'Show_Employee.php';</script><?php
//header("Refresh:0; url=Show_Employee.php");
}
}
else
{?><script language="javascript" type="text/javascript">alert("ไม่สามารภบันทึกข้อมูลพนักงานได้");</script><?php }
} ?>
Tag : PHP, MySQL, HTML/CSS, JavaScript
|
|
 |
 |
 |
 |
Date :
2013-09-23 11:35:13 |
By :
nutzaaclub |
View :
1014 |
Reply :
12 |
|
 |
 |
 |
 |
|
|
|
 |