|
|
|
รบกวนดูโค้ดให้ทีคับ อยากให้รับข้อมูลเสร็จแล้วกลับไปฟอร์มเดิม |
|
|
|
|
|
|
|
เมื่อรับข้อมูลเสร็จแล้วอยากให้มันกลับไปยังหน้าฟอร์มอีกครั้ง และ ให้มันแสดง ด้วย id
เช่น editpage.php?id=1
จะเขียนอย่างไรดีครับ
Code (PHP)
<?php
include_once "../../includes/functionLib.php";
if($_POST){
$studentCode = $_POST["studentCode"];
$studentPrename = trim($_POST["studentPrename"]);
$studentFirstname = trim($_POST["studentFirstname"]);
$studentLastname = trim($_POST["studentLastname"]);
$studentNickname = trim($_POST["studentNickname"]);
$studentNo = trim($_POST["studentNo"]);
$studentBuildingname = trim($_POST["studentBuildingname"]);
$studentSoi = trim($_POST["studentSoi"]);
$studentRoad = trim($_POST["studentRoad"]);
$studentDistrict = trim($_POST["studentDistrict"]);
$studentAmphur = trim($_POST["studentAmphur"]);
$studentProvince = trim($_POST["studentProvince"]);
$studentPostcode = trim($_POST["studentPostcode"]);
$studentPhone = trim($_POST["studentPhone"]);
$studentMobile = trim($_POST["studentMobile"]);
$studentEmail = trim($_POST["studentEmail"]);
$studentBirthday = trim($_POST["studentBirthday"]);
$studentRemark = trim($_POST["studentRemark"]);
//chack student wa sum mai & db
$strSQL = "SELECT * FROM student WHERE studentCode = '".$_POST["studentCode"]."' ";
$objRec = $db->Execute($strSQL);
if(!$objRec->EOF)
{
//echo("ContactCode already exist.");
}
else
{
$strSQL = "";
$strSQL .= "INSERT INTO student";
$strSQL .= "(studentCode, studentPrename, studentFirstname, studentLastname, studentNickname, studentNo, studentBuildingname, studentSoi, studentRoad, studentDistrict, studentAmphur, studentProvince, studentPostcode, studentPhone, studentMobile, studentEmail, studentBirthday, studentRemark) ";
$strSQL .= "VALUES ";
$strSQL .= "('".$_POST["studentCode"]."',";
$strSQL .= "'".$_POST["studentPrename"]."',";
$strSQL .= "'".$_POST["studentFirstname"]."',";
$strSQL .= "'".$_POST["studentLastname"]."',";
$strSQL .= "'".$_POST["studentNickname"]."',";
$strSQL .= "'".$_POST["studentNo"]."',";
$strSQL .= "'".$_POST["studentBuildingname"]."',";
$strSQL .= "'".$_POST["studentSoi"]."',";
$strSQL .= "'".$_POST["studentRoad"]."',";
$strSQL .= "'".$_POST["studentDistrict"]."',";
$strSQL .= "'".$_POST["studentAmphur"]."',";
$strSQL .= "'".$_POST["studentProvince"]."',";
$strSQL .= "'".$_POST["studentPostcode"]."',";
$strSQL .= "'".$_POST["studentPhone"]."',";
$strSQL .= "'".$_POST["studentMobile"]."',";
$strSQL .= "'".$_POST["studentEmail"]."',";
$strSQL .= "'".$_POST["studentBirthday"]."',";
$strSQL .= "'".$_POST["studentRemark"]."')";
$flgSave = $db->Execute($strSQL);
//or die(MYSQL_error() chack error *petch comment
If($flgSave)
{
echo("Save Done.");
echo '<br>';
echo 'Now: '. date('Y-m-d') ."\n";
}
else
{
echo("Error Save");
}
}
}//end $_POST
//show province wow
foreach($province_type as $key){
$tmp['value1'] = $key;
$tmp['province_name'] = $key;
$data1[] = $tmp;
}
$smarty->assign("province_type",$data1);
//end province
//show proname
foreach($prename_type as $key){
$tmp['value2'] = $key;
$tmp['prename_name'] = $key;
$data2[] = $tmp;
}
$smarty->assign("prename_type",$data2);
//endprename
//$smarty->assign("data",$data);
$smarty->assign("title_web",$title_website);
$smarty->assign("docs_path",$DirectoryURL);
#Êèǹ¢Í§¡Òà display
$smarty->display("student-add.tpl");
?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-03-22 14:51:55 |
By :
crazyaholic |
View :
823 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณคับ แล้วต้องดึงid ขึ้นมาเก็บก่อนไมคับ
|
|
|
|
|
Date :
2011-03-22 16:44:17 |
By :
crazyaholic |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะดึงหรือเรียกตรงๆเลยก็ได้ครับ
|
|
|
|
|
Date :
2011-03-22 16:50:07 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|