<? session_start(); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="refresh" content="5; url=random_check.php;"> <? if(!isset($_SESSION['username'])) { echo"<script>alert('คุณยังไม่ได้เข้าสู่ระบบ!!');window.location='index.php';</script>"; exit(); } ?> <script language="javascript"> window.history.forward(-1); </script> <body> <body onLoad="begintimer()"> <script language=""> var limit="0:10" if (document.images){ var parselimit=limit.split(":") parselimit=parselimit[0]*60+parselimit[1]*1 } function begintimer(){ if (!document.images) return if (parselimit==1){ // เหตุการณ์ที่ต้องการให้เกิดขึ้น window.location='random_check.php';// ถ้าต้องการให้กระโดดไปยัง Page อื่น frmTest.submit();} else{ parselimit-=1 curmin=Math.floor(parselimit/60) cursec=parselimit%60 if (curmin!=0) curtime="เวลาที่เหลือ <font color=red> "+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที " else if(cursec==0) { alert('หมดเวลาแล้วจ้า'); } else { curtime="เวลาที่เหลือ <font color=red>"+cursec+" </font>วินาที " } document.getElementById('dplay').innerHTML = curtime; setTimeout("begintimer()",1000) } } //--> </script> <div id=dplay ></div> <FORM METHOD="POST" name="frmTest" ACTION="random_check.php" enctype="multipart/form-data"> <?php $number=1; $test_subject=$_GET[test_subject]; include "connect.php"; $sql="SELECT tb_test.* FROM tb_test,subject where tb_test.sj_id=subject.sj_id and tb_test.sj_id='$test_subject' ORDER BY RAND() LIMIT 0,20"; $result=mysql_db_query("$dbname",$sql); while ($r=mysql_fetch_array($result)) { $id=$r[id]; $question=$r[question]; $picture=$r[picture]; $choice1=$r[choice1]; $choice2=$r[choice2]; $choice3=$r[choice3]; $choice4=$r[choice4]; if($picture!=""){ echo "<B>ข้อ $number. $question </B><BR> <img src='admin/images/$picture'><BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='1'> $choice1 <BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='2'> $choice2 <BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='3'> $choice3 <BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='4'> $choice4 <INPUT TYPE='hidden' NAME='total_question[]' VALUE='$id'> <INPUT TYPE='hidden' NAME='test_subject' VALUE='$test_subject'> <HR> "; $number++; } else{ echo "<B>ข้อ $number. $question </B><BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='1'> $choice1 <BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='2'> $choice2 <BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='3'> $choice3 <BR> <INPUT TYPE='radio' NAME='select_$id' VALUE='4'> $choice4 <INPUT TYPE='hidden' NAME='total_question[]' VALUE='$id'> <INPUT TYPE='hidden' NAME='test_subject' VALUE='$test_subject'> <HR> "; $number++; } } ?> <INPUT TYPE="submit" VALUE="ส่งคำตอบ"> </FORM> </body>
<? session_start(); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <? if(!isset($_SESSION['username'])) { echo"<script>alert('คุณยังไม่ได้เข้าสู่ระบบ!!');window.location='index.php';</script>"; exit(); } ?> <? $total_question=$_POST['total_question']; $test_subject=$_POST['test_subject']; $correct=0; $total=count($total_question); include "connect.php"; $sql="select id,answer from tb_test order by id"; $result=mysql_db_query("$dbname",$sql); while ($r=mysql_fetch_array($result)) { $id=$r[id]; $answer=$r[answer]; if (in_array($id,$total_question)) { $select = $_POST["select_".$id]; if ($select==$answer) { $correct++; } } } $username=$_SESSION['username']; $today = date("Y-m-d"); $sql2 = "select sj_id from tb_score where mem_user ='$username' and sj_id='$test_subject' "; $rs = mysql_query($sql2)or die('ประมวผลไม่ได้ '.$sql2.'<br>เนื่องจาก: ' . mysql_error()); $row = mysql_fetch_array($rs); if($row[sj_id]!=$test_subject){ $sql3="insert into tb_score values('','$username','$test_subject','$correct','$today')"; }else{ echo"<script>alert('คุณสอบวิชานี้ไปแล้วครับ!!');window.location='index.php';</script>"; } mysql_query($sql3)or die('ประมวผลไม่ได้ '.$sql3.'<br>เนื่องจาก: ' . mysql_error()); echo "<h2>ถูกต้องทั้งหมด $correct ข้อ <BR>ข้อสอบทั้งหมด $total ข้อ</h2>"; ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง