-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-specific-jun-member-exec.php
151 lines (125 loc) · 4.6 KB
/
get-specific-jun-member-exec.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
//Run the authentication script
require_once('auth.php');
//To handle output buffer
ob_start();
//Start session
session_start();
//Include database connection details
require_once('config.php');
require_once('functions.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Query to get all information about a member
$qry = "SELECT * FROM crew WHERE crew_id='".clean($_POST['activeJunMemberSelect'])."'";
$result = @mysql_query($qry);
if($result) {
$member = mysql_fetch_assoc($result);
//Array to store new member form data in
$member_data['selected_member'] = $_POST['activeJunMemberSelect'];
$member_data['name'] = $member['firstname'].' '.$member['lastname'];
$member_data['dob'] = substr($member['dob'],-2,2).'.'.substr($member['dob'],-5,2).'-'.substr($member['dob'],-10,4);
$member_data['age'] = calculate_age($member['dob']);
$member_data['nameice'] = $member['nameice'];
$member_data['ice'] = $member['ice'];
$member_data['juniorstarted'] = $member['juniorstarted'];
//Check if member has an phone number
if($member['phone'] != '') {
$member_data['phone'] = $member['phone'];
} else {
$member_data['phone'] = '-';
}
//Check if member has an email
if($member['email'] != '') {
$member_data['email'] = $member['email'];
} else {
$member_data['email'] = '-';
}
//Check if member has any sweater size
if($member['size'] != '') {
$member_data['size'] = $member['size'];
} else {
$member_data['size'] = '-';
}
//Variable to store education as junior
$junior_education = '';
//Check if junior has done beginner education and concat result to education string
if($member['beginner'] != 'not_done') {
$junior_education = $junior_education.'Nybörjarkurs('.$member['beginner'].')';
}
//Check if junior has done level one education and concat result to education string
if($member['lvlone'] != 'not_done') {
if($junior_education == '') {
$junior_education = $junior_education.'Nivåkurs 1('.$member['lvlone'].')';
} else {
$junior_education = $junior_education.', Nivåkurs 1('.$member['lvlone'].')';
}
}
//Check if junior has done level two education and concat result to education string
if($member['lvltwo'] != 'not_done') {
if($junior_education == '') {
$junior_education = $junior_education.'Nivåkurs 2('.$member['lvltwo'].')';
} else {
$junior_education = $junior_education.', Nivåkurs 2('.$member['lvltwo'].')';
}
}
//Check if junior has done level three education and concat result to education string
if($member['lvlthree'] != 'not_done') {
if($junior_education == '') {
$junior_education = $junior_education.'Nivåkurs 3('.$member['lvlthree'].')';
} else {
$junior_education = $junior_education.', Nivåkurs 3('.$member['lvlthree'].')';
}
}
//Check if junior has done level four education and concat result to education string
if($member['lvlfour'] != 'not_done') {
if($junior_education == '') {
$junior_education = $junior_education.'Nivåkurs 4('.$member['lvlfour'].')';
} else {
$junior_education = $junior_education.', Nivåkurs 4('.$member['lvlfour'].')';
}
}
//Check if junior has done unit commander education and concat result to education string
if($member['jununitcommander'] != 'not_done') {
if($junior_education == '') {
$junior_education = $junior_education.'Gruppchef('.$member['jununitcommander'].')';
} else {
$junior_education = $junior_education.', Gruppchef('.$member['jununitcommander'].')';
}
}
//Check if junior has done education course and concat result to education string
if($member['education'] != 'not_done') {
if($junior_education == '') {
$junior_education = $junior_education.'Utbildarkurs('.$member['education'].')';
} else {
$junior_education = $junior_education.', Utbildarkurs('.$member['education'].')';
}
}
//If member hasn't done any courses
if($junior_education == '') {
//$junior_education = 'Har ej genomfört några utbildningar.';
$junior_education = '-';
}
$member_data['education'] = $junior_education;
//Store new member data array as Session
$_SESSION['MEMBER_DATA'] = $member_data;
session_write_close();
ob_clean();
header("location: get-specific-jun-member.php");
exit();
} else {
die(mysql_error());
}
?>