-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle_update.php
95 lines (77 loc) · 4.32 KB
/
single_update.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
<?php
require 'db.php';
$id=$_POST['id'];
$work_date='';
$work_progress = $_POST['work_progress'];
$work_comment = $_POST['work_comment'];
$work = $_POST['work'];
$report_comment = $_POST['report_comment'];
$report_progress = $_POST['report_progress'];
$report = $_POST['report'];
$phase1 = $_GET['ph1'];
$phase2 = $_GET['ph2'];
$phase3 = $_GET['ph3'];
$phase4 = $_GET['ph4'];
$select = "SELECT * FROM users WHERE id='$id'";
$select_result = mysqli_query($db,$select);
$after_assoc = mysqli_fetch_assoc($select_result);
$vid = $after_assoc['vid'];
$select_work = "SELECT COUNT(*) as work FROM progress_test WHERE status=1 and vid='$vid' and stu_id='$id' and phase=$phase1";
$select_result_work = mysqli_fetch_assoc(mysqli_query($db,$select_work));
$select_report = "SELECT COUNT(*) as report FROM progress_test WHERE status=2 and vid='$vid' and stu_id='$id' and phase=$phase2";
$select_result_report = mysqli_fetch_assoc(mysqli_query($db,$select_report));
if ($phase1==1) {
if ($work==1 && $select_result_work['work'] < 2 && !empty($work_progress)&&!empty($work_comment)) {
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$work_progress','$work_comment','$vid','$work','$phase1')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}elseif($report==2 && $select_result_report['report'] < 2 && !empty($report_progress)&&!empty($report_comment)){
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$report_progress','$report_comment','$vid','$report','$phase1')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}else{
header('location:single_user.php?id='.$id);
}
}
elseif($phase2==2){
if ($work==1 && $select_result_work['work'] < 2 && !empty($work_progress)&&!empty($work_comment)) {
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$work_progress','$work_comment','$vid','$work','$phase2')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}elseif($report==2 && $select_result_report['report'] < 2 && !empty($report_progress)&&!empty($report_comment)){
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$report_progress','$report_comment','$vid','$report','$phase2')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}else{
header('location:single_users.php?id='.$id);
}
}elseif($phase3==3){
if ($work==1 && $select_result_work['work'] < 2 && !empty($work_progress)&&!empty($work_comment)) {
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$work_progress','$work_comment','$vid','$work','$phase3')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}elseif($report==2 && $select_result_report['report'] < 2 && !empty($report_progress)&&!empty($report_comment)){
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$report_progress','$report_comment','$vid','$report','$phase3')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}else{
header('location:single_users.php?id='.$id);
}
}elseif($phase4==4){
if ($work==1 && $select_result_work['work'] < 2 && !empty($work_progress)&&!empty($work_comment)) {
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$work_progress','$work_comment','$vid','$work','$phase4')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}elseif($report==2 && $select_result_report['report'] < 2 && !empty($report_progress)&&!empty($report_comment)){
$update = "INSERT INTO progress_test (stu_id,progress,comment,vid,status,phase) VALUES('$id','$report_progress','$report_comment','$vid','$report','$phase4')";
$insert_result= mysqli_query($db, $update);
header('location:single_users.php?id='.$id);
}else{
header('location:single_users.php?id='.$id);
}
}
else {
echo 'bahir';
// header('location:edit_users.php?id='.$id);
}
?>