<?php
error_reporting(0);
$link=@mysql_connect("localhost" , "tad0616" ,"12345");
if(!$link) echo "資料庫連不上!";
//設定使用UTF8編碼
mysql_query("SET NAMES 'utf8'");
//選擇資料庫
mysql_select_db('tad0616');
$op=isset($_POST['op'])?$_POST['op']:"";
$class_sn=isset($_POST['class_sn'])?intval($_POST['class_sn']):"";
if($op=="update"){
//SQL更新語法
$sql="update tncomu_class set `seme`='{$_POST['seme']}', `subject`='{$_POST['subject']}', `class_name`='{$_POST['class_name']}', `teacher`='{$_POST['teacher']}', `passwd`='{$_POST['passwd']}', `access`='{$_POST['access']}' where class_sn='$class_sn'";
}else{
//SQL新增語法
$sql="insert into tncomu_class (`seme`, `subject`, `class_name`, `teacher`, `passwd`, `access`) values('{$_POST['seme']}' , '{$_POST['subject']}' , '{$_POST['class_name']}' , '{$_POST['teacher']}' , '{$_POST['passwd']}' , '{$_POST['access']}')";
}
//執行SQL語法
mysql_query($sql) or die("無法執行:".mysql_error());
//執行完轉向
header("location: index.php");
?>