 |
|
if(ตรวจหลายๆตัวแปร) เขียนยังไงให้ถูก ตรวจสอบว่า ใส่ตัวแปรครบหรือไหม ถ้าไม่จะไม่บันทึกลงฐานข้อมูล
Code (PHP)
switch($cmd){
case add:
if($id_student=='' and $id_number=='' and $type_student=='' and $lastname_field=='' and $level_field=='' and $year_data_field=='' )
{
echo "กรอกข้อมูลไม่ครบ กรุณาตรวจสอบข้อมุลของท่านด้วย $id_student $id_number $type_student$lastname_field$level_field$year_data_field";
}else{
$sql="insert into students (id_student,id_number,type_student,name,lastname,level,room,year_data,phonenumber,level_access) VALUES ('$id_student','$id_number','$type_student','$name_field','$lastname_field','$level_field','$room_field','$year_data_field','$phonenumber','1')";
$result=mysql_query($sql);
if($result){
$smarty->assign("id",$name_field);
$smarty->assign("stauts_update",'Successful'.$name_field);
$smarty->assign("stauts_update2",'ระบบได้รับข้อมูลของท่านแล้ว รอสักครู่ เพื่อกลับหน้าหลัก"'.$name_field);
$smarty->assign("stauts_update3",'Back to main page'.$name_field);
$smarty->display('system.html');
}
else {
$smarty->assign("stauts_update",'มีข้อผิดพลาดทางระบบ'.$name_field);
$smarty->display('system.html');
} };
break;
ขอบคุณครับ
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2011-11-17 14:57:19 |
By :
icman |
View :
3244 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |