<?php
session_start();
if($_SESSION['id_siswa']!=''){
include"../inc/conn.php";

$id_siswa   = str_replace("'","`",(isset($_POST['id_siswa'])) ? $_POST['id_siswa'] : "");
$id_unit    = str_replace("'","`",(isset($_POST['id_unit'])) ? $_POST['id_unit'] : "");
$id_essai   = str_replace("'","`",(isset($_POST['id_essai'])) ? $_POST['id_essai'] : "");

$count = count($id_essai);
for($i=0;$i<$count;$i++){

  $simpan = mysqli_query($connect,"insert into tb_jawaban set

    id_siswa      = '".$id_siswa."',
    id_unit       = '".$id_unit."',
    id_essai      = '".$id_essai[$i]."',
    jawaban       = '".$_POST['jawaban'.$id_essai[$i]]."'") or die(mysqli_error($connect));

}

echo"<script>alert('Jawaban anda telah tersimpan !');</script>";
echo"<script>document.location.href='ujikonsep.php?id=$id_unit'</script>";



}else{
  echo"<script>document.location.href='index.php'</script>";
}
?>