-
Notifications
You must be signed in to change notification settings - Fork 5
/
add_account_check.php
87 lines (79 loc) · 2.79 KB
/
add_account_check.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<script language="javascript" type="text/javascript" src="include/head.js"></script>
<meta charset="utf-8">
<title>민사페이 계좌 등록 확인</title>
</head>
</html>
<?php
session_start();
//세션이 존재하지 않을 때 == 로그인이 아직 안 되어 있을 때
if(!isset($_SESSION['userid']))
{
header ('Location: ./main.php');
exit();
}
//세션이 존재할 때 == 로그인이 되어 있을 때
$id = $_SESSION['userid'];
require('db.php');
$check="SELECT * FROM user_info WHERE userid='$id'";
$result=$mysqli->query($check);
$row=$result->fetch_array(MYSQLI_ASSOC);
$boothname = $row['boothname'];
$isAdmin = $row['admin'];
//일반 부스 운영자가 들어왔을 때: 자기 위치로 이동
if($isAdmin != 1)
{
header ('Location: ./main.php');
exit();
}
else
{
// 행정위 직원이 들어왔을 때(정상적인 상황)
$numid=$_POST['id'];
if (isset($_POST['freepass']) && $_POST['freepass'] == 'yes')
$freepass=1;
else
$freepass=0;
switch($_POST['info'])
{
case "senior":
$balance=7000;
break;
case "teacher":
$balance=10000;
break;
default:
$balance=0;
}
$rfid=$_POST['rfid'];
if($numid==NULL || $rfid==NULL)
{
echo "빈 칸을 모두 채워주세요";
echo "<br><button onclick=\"location.href='add_account.php'\"> 돌아가기 </button>";
exit();
}
$check="SELECT *from account_info WHERE rfid='$rfid'";
$result=$mysqli->query($check);
if($result->num_rows==1)
{
echo "이미 등록된 학생증입니다.";
echo "<br><button onclick=\"location.href='main.php'\"> 돌아가기 </button>";
exit();
}
$date = date("m/d h:i:s",strtotime ("+9 hours"));
$query = "INSERT INTO account_info (rfid,balance,freepass,idnumber) VALUES ('$rfid','$balance','$freepass','$numid'); ";
$query .= "INSERT INTO transaction_list (who,booth,what,balance, timestamp, price) VALUES ('$numid','$boothname',0,'$balance','$date','$balance')";
if (mysqli_multi_query($mysqli, $query))
{
?>
<meta charset="utf-8" />
<script type="text/javascript">alert('계좌 등록이 완료되었습니다.');</script>
<meta http-equiv="refresh" content="0;url=/main.php">
<?php
}
else
echo "<br><button onclick=\"location.href='main.php'\"> 계좌 등록 실패, 돌아가기 </button>";
}
?>