Viewing file: InsertStudent.php (6.01 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php session_start(); if (session_is_registered("valid_user")) { include("../../include/FunctionDB.php"); include("../../include/Function.php"); ConnectDB(); $Flag = true; $Student_id = htmlspecialchars(trim($_POST[Student_id])); $Course_code = htmlspecialchars(trim($_POST[Course_code])); $Class = htmlspecialchars(trim($_POST['Class'])); $Orderlist = htmlspecialchars(trim($_POST[Orderlist])); $First_name = htmlspecialchars(trim($_POST[First_name])); $Name = htmlspecialchars(trim($_POST[Name])); $Lastname = htmlspecialchars(trim($_POST[Lastname])); $Address = htmlspecialchars(trim($_POST[Address])); $Sex = trim( $_POST[Sex]); $DateBirth = $_POST[mYear]."-".$_POST[mMonth]."-".$_POST[mDate]; $Father_name = htmlspecialchars(trim($_POST[Father_name])); $Mother_name = htmlspecialchars(trim($_POST[Mother_name])); $Address2 = htmlspecialchars(trim($_POST[Address2])); $Telno = htmlspecialchars(trim($_POST[Telno])); $Date_in = $_POST[mYear2]."-".$_POST[mMonth2]."-".$_POST[mDate2]; $Term = trim($_POST[Term]);
/////////////// Check Duplicate Std Id ///////////////////////////////////// $sql3 = "Select * From student_tb Where Student_id='$Student_id'"; $result3 = mysql_query($sql3) or die("Error $result3".mysql_error()); $Check= mysql_num_rows($result3); if ($Check >0) { $msg .="<li>รหัสนักศึกษารหัส $Student_id มีในฐานข้อมูลแล้ว"; $button ="<input type=\"button\" value=\"Back to Edit\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">"; $Flag = false; } ////////////////////////// check First name if ($First_name =="") { $msg .="<li>กรุณาระบุ คำนำหน้า"; $button ="<input type=\"button\" value=\"กลับไปแก้ไข\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">"; $Flag = false; } ///////////////////// check name if ($Name =="") { $msg .="<li>กรุณาระบุ ชื่อ"; $button ="<input type=\"button\" value=\"กลับไปแก้ไข\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">"; $Flag = false; } /////////////////// Check Lastname if ($Lastname =="") { $msg .="<li>กรุณาระบุ นามสกุล"; $button ="<input type=\"button\" value=\"กลับไปแก้ไข\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">"; $Flag = false; } ////////////////////////// check First name if ($Sex =="") { $msg .="<li>กรุณาระบุ เพศ"; $button ="<input type=\"button\" value=\"กลับไปแก้ไข\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">"; $Flag = false; } //////////////////////// /*if ( ! CheckLenght($Student_id,7)) { $msg .= "<li>รหัสนักศึกษาต้องมีตั้งแต่ 7 หลัก"; $button = "<input type=\"button\" value=\"กลับไปแก้ไข\" onclick=\"history.back();\" style=\"font-weight:bold; color:#FFF; background-color:#036; border-style:outset; border-color:#69F; font-family: Tahoma;\">"; $Flag = false; }*/ /////////////////////// Check Address if ($Address=="") { $msg .="<li>กรุณาระบุ ภูมิลำเนา"; $button ="<input type=\"button\" value=\"กลับไปแก้ไข\" onclick=\"history.back();\" style=\"font-weight:bold;color:#FFF;background-color:#036;border-style:outset;border-color:#69F;font-family:Tohoma;\">"; $Flag = false; }
///////////////////////// Check Status to Insert Data /////////////////////////////
if( $Flag) { $Path = "../../Std_pic"; if ( isset($Img1) ) if (copy($Img1,"$Path/$Img1_name")) { unlink ($Img1); $Img1 = "$Path/$Img1_name"; } else echo"Can't Copy"; InsertStudent($Course_code,$Class,$Orderlist,$Student_id,$First_name,$Name,$Lastname,$Sex,$DateBirth,$Religion,$Address,$Img1,$Father_name,$Mother_name,$Address2,$Telno,$Pre_inst,$Pre_gpa,$Select_Method,$Term,$Date_in,$Institute,$Teacher_code,$Affect_class,$Scholarship_code,$Address_cur,$Coll_in,$Coll_out,$Circle_duty,$Circle,$Succ_Status) ; $msg.="<li>$Student_id<b>$Name $Lastname</b>"; $msg.="<li>ระบบจัดเก็บข้อมูลเรียบร้อยแล้ว"; echo"<meta http-equiv=\"refresh\" content=\"1;URL=StudentList.php\">\n"; } CloseDB(); ?> <html> <head> <title>Student</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-874"> <link rel="stylesheet" href="/css/style1.css" type="text/css"> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0"marginwidth="0"marginheight="0"> <form> <br> <table width="70%" border="0" cellspacing="0"cellpadding="2"align="center"> <tr> <td><div align="center"><span><b><font color="#003399" size="4" face="Tahoma">::แบบฟอร์มกรอกข้อมูลนักศึกษา::</font></b></span></div></td> </tr> <tr> <td> <table width="100%" border="0" cellspacing="1"cellpadding="0"align="center" class="table"> <tr> <td bgcolor="#AFCFEF"><b><font color="#003333" size="3" face="Tahoma">ระบบแจ้งการทำงาน</font></b></td> </tr> <tr> <td bgcolor="#000000"> <table width="90%" border="0" cellspacing="0"cellpadding="2"align="center"> <tr> <td><span><b><font color="#FFFFFF"><?php echo $msg;?></font></b></span></td> </tr> </table> </td> </tr> <tr> <td bgcolor="#AFCFEF"> <div align="center"><b><font color="#CCFF00"><?php echo $button;?> <font size="2" face="Tahoma"></font></font></b></div></td> </tr> </table> </td> </tr> </table> <br> </form> </body> </html> <?php } else { echo"<body bgcolor=\"#CCCCCC\">"; echo"<meta http-equiv=\"refresh\" content=\"3;URL=../logout.php\" target=\"mainFrame\">\n"; echo"<center>"; echo"<br><br><br><b><font face=\"Tahoma\" size=\"4\" color=\"#FF0000\">Please Login</font> </b><br>"; echo"<br><br><font face=\"Tahoma\" size=\"10\" color=\"#000000\"> ERROR 404 PERMISION DENY</font><br>"; echo"<br><font face=\"Tahoma\" size=\"4\" color=\"#000000\"> คุณไม่มสิทธ์ใช้งาน</font>"; echo"</center>"; echo"</body>"; } ?>
|