Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php error_reporting(0);
- date_default_timezone_set("Asia/Jakarta");
- mysql_connect('localhost','root',''); mysql_select_db('idu_timebox');
- if(isset($_POST['id'])){
- $id = mysql_real_escape_string($_POST['id']);
- $a = mysql_fetch_array(mysql_query("select * from tabel_form where id='$id'"));
- if($a){
- function cek($id){
- $a = mysql_fetch_array(mysql_query("select * from tabel_form where id='$id'"));
- $tgl = date('Y-m-d');
- $jam = date('H:i:s');
- /*
- 08.00-08.15 : 5
- 10.00-10.15 : 2
- 12.00-12.15 : 1
- 15.00-15.15 : 2
- 19.00-19.15 : 5
- */
- // cek absen dulu
- if($jam>="08:00:00" and $jam<="08:15:00"){
- $_b = mysql_query("select * from tabel_absen where nama='$a[nama]' and tgl='$tgl'");
- while($b = mysql_fetch_array($_b)){
- if($b['jam']>="08:00:00" and $b['jam']<="08:15:00"){
- $t1= 1;
- }else{
- $t1=0;
- }
- }
- if($t1==0 or empty($t1)){
- $p=5;
- mysql_query("insert into tabel_absen(nama,tgl,jam,point) values('$a[nama]','$tgl','$jam','$p')");
- }
- }elseif($jam>="10:00:00" and $jam<="10:15:00"){
- $_b = mysql_query("select * from tabel_absen where nama='$a[nama]' and tgl='$tgl'");
- while($b = mysql_fetch_array($_b)){
- if($b['jam']>="10:00:00" and $b['jam']<="10:15:00"){
- $t2= 1;
- }else{
- $t2=0;
- }
- }
- if($t2==0 or empty($t2)){
- $p=2;
- mysql_query("insert into tabel_absen(nama,tgl,jam,point) values('$a[nama]','$tgl','$jam','$p')");
- }
- }elseif($jam>="12:00:00" and $jam<="12:15:00"){
- $_b = mysql_query("select * from tabel_absen where nama='$a[nama]' and tgl='$tgl'");
- while($b = mysql_fetch_array($_b)){
- if($b['jam']>="12:00:00" and $b['jam']<="12:15:00"){
- $t3= 1;
- }else{
- $t3=0;
- }
- }
- if($t3==0 or empty($t3)){
- $p=1;
- mysql_query("insert into tabel_absen(nama,tgl,jam,point) values('$a[nama]','$tgl','$jam','$p')");
- }
- }elseif($jam>="15:00:00" and $jam<="15:15:00"){
- $_b = mysql_query("select * from tabel_absen where nama='$a[nama]' and tgl='$tgl'");
- while($b = mysql_fetch_array($_b)){
- if($b['jam']>="15:00:00" and $b['jam']<="15:15:00"){
- $t4= 1;
- }else{
- $t4=0;
- }
- }
- if($t4==0 or empty($t4)){
- $p=2;
- mysql_query("insert into tabel_absen(nama,tgl,jam,point) values('$a[nama]','$tgl','$jam','$p')");
- }
- }elseif($jam>="19:00:00" and $jam<="19:15:00"){
- $_b = mysql_query("select * from tabel_absen where nama='$a[nama]' and tgl='$tgl'");
- while($b = mysql_fetch_array($_b)){
- if($b['jam']>="19:00:00" and $b['jam']<="19:15:00"){
- $t5= 1;
- }else{
- $t5=0;
- }
- }
- if($t5==0 or empty($t5)){
- $p=5;
- mysql_query("insert into tabel_absen(nama,tgl,jam,point) values('$a[nama]','$tgl','$jam','$p')");
- }
- }else{
- $p=0;
- mysql_query("insert into tabel_absen(nama,tgl,jam,point) values('$a[nama]','$tgl','$jam','0')");
- }
- echo "<!-- AaEzha van Ilmi has helped her -->";
- }
- function updet($id){
- $a = mysql_fetch_array(mysql_query("select * from tabel_form where id='$id'"));
- $aa = mysql_query("select * from tabel_absen where nama='$a[nama]'");
- $p = 0;
- while($b = mysql_fetch_array($aa)){
- $t = $b['point'];
- $p = $p + $t;
- }
- mysql_query("update tabel_form set total_point='$p' where id='$id'");
- }
- cek($id); updet($id);
- echo " <a href=\"timebox.php\">Kembali</a>";
- }else{
- echo "<a href=\"timebox.php\">Not found. Kembali</a>";
- }
- }else{
- ?>
- <form action="" method="post">
- <input type="password" name="id" required>
- <input type="submit" value="Tap!">
- </form>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement