<?php
include "connect.php";

$tgl_byr  = $_GET['tgl_byr'];
$nim   = $_COOKIE['nim'];
$kd_byr   = $_COOKIE['kd_byr'];
$jum_byr   = $_GET['jum_byr'];

//simpan data
$input ="insert into tb_byr(tgl_byr,nim,kd_byr,jum_byr)
 values('$tgl_byr','$nim','$kd_byr','$jum_byr')";
mysql_query($input);
if ($input)
{
$cek = mysql_query("select * from temp where nim='$nim' AND kd_byr='$kd_byr'");
$hasil=mysql_num_rows($cek);
$hasil2=mysql_fetch_row($cek);
if($hasil>0)
	{
	$updt_byr = $jum_byr + $hasil2[2];
	$update ="update temp set temp_byr='$updt_byr' where nim='$nim' AND kd_byr='$kd_byr'";
 	$hasil = mysql_query($update);
	header("location:fkwi.php");
	}
	else
	{
	$input ="insert into temp(nim,kd_byr,temp_byr)
 	values('$nim','$kd_byr','$jum_byr')";
	mysql_query($input);
	header("location:fkwi.php");
	}
}
else
{
echo "Poses Input Gagal";
}
?>

