-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddData.php
143 lines (120 loc) · 5.57 KB
/
AddData.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
<?php
include("ConfigDB.php");
AddDateID($TodayDate, $DB);
//If user hasnt logged in this will force him to go to login page
Authunticate();
//Store Today's Date in $Day_ID Variable
$Day_ID = $_SESSION['Day_ID'];
$User_ID = $_SESSION['UserID'];
// Insert Into `To-Do-List` Table New Task For Today's Date
if (isset($_POST['To-Do-ListBTN'])) {
$Note = $_POST['NoteIN'];
$InsertQueryToToDoListT = " INSERT INTO `to-do-list` VALUES (NULL,$Day_ID,'$Note',0,$User_ID)";
$ExceuteAboveQuery = mysqli_query($DB, $InsertQueryToToDoListT);
if ($ExceuteAboveQuery) PrintMessage("Done Adding New Task", "Normal");
else echo PrintMessage("Failed Adding New Task", "Danger");
}
// Insert Into `Diary` Table New Diary For Today's Date
if (isset($_POST['DiaryBTN'])) {
$Diary = nl2br($_POST['DiaryIN']);
$InsertQueryDiaryT = " INSERT INTO `diary` VALUES (NULL,$Day_ID,'$Diary',$User_ID)";
$ExceuteAboveQuery = mysqli_query($DB, $InsertQueryDiaryT);
if ($ExceuteAboveQuery) PrintMessage("Done Adding Today's Diary", "Normal");
else echo PrintMessage("Failed Adding Today's Diary", "Danger");
}
// Insert Into `answer_of_questions` Table New Answer of a specific Question For Today's Date
if (isset($_POST['AnswerBTN'])) {
$Answer = $_POST['AnswerIN'];
$QuestionID = $_POST['QuestionID'];
$InsertQueryAnswerT = " INSERT INTO `answer_of_questions` VALUES (NULL,$Day_ID,'$QuestionID','$Answer',$User_ID)";
$ExceuteAboveQuery = mysqli_query($DB, $InsertQueryAnswerT);
if ($ExceuteAboveQuery) PrintMessage("Done Adding Answer Of Specific Question", "Normal");
else echo PrintMessage("Failed Adding Answer Of Specific Question", "Danger");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
input,
textarea {
unicode-bidi: plaintext;
}
</style>
</head>
<body>
<h1 style="font-style: italic;margin:15px auto">Add Data Page </h1>
<h4>Today's Date : <b style="color:cadetblue;"><?php echo $TodayDate ?> </b> </h4>
<!-- To-Do-List Container Start -->
<div class="To-Do-List Container">
<h1>To-Do-List</h1>
<div>
<form action="" method="POST">
<div class="row-6">
<div class="col">
<label style="font-weight: bold;" for="NoteIN"> Note :</label>
<input id="AddData" class="form-control " type="text" name="NoteIN" id="NoteIN" placeholder="Enter Task Here">
</div>
</div>
<div class="col">
<div class="row justify-content-center align-items-center">
<button style="margin-top: 20px;" type="submit" name="To-Do-ListBTN" class="btn btn-outline-primary text-center">Add task</button>
</div>
</div>
</form>
</div>
</div>
<!-- To-Do-List Container End -->
<!-- Diary Container Start -->
<div class="Diary Container">
<h1>Today's Diary</h1>
<div>
<form action="" method="POST">
<div class="row-6">
<div class="col">
<label style="font-weight: bold;" for="DiaryIN"> Diary :</label>
<textarea style="text-align: center;" class="form-control" type="text" name="DiaryIN" id="DiaryIN" placeholder="Enter Diary Here"></textarea>
</div>
</div>
<div class="col">
<div class="row justify-content-center align-items-center">
<button style="margin-top: 20px;" type="submit" name="DiaryBTN" class="btn btn-outline-warning text-center">Add Diary</button>
</div>
</div>
</form>
</div>
</div>
<!-- Diary Container End -->
<table class="table table-dark container Container">
<tr>
<th>Question</th>
<th>Input</th>
<th>Input</th>
</tr>
<?php
//echo $Day_ID;
$SelectQuery = " SELECT ANSWERS_TABLE.Date_ID AS DID , ANSWERS_TABLE.Answer AS ANSWER , QUESTIONS_TABLE.Question AS QUESTION_COL , QUESTIONS_TABLE.ID AS QUESTION_ID
FROM `predefined-questions` AS QUESTIONS_TABLE LEFT JOIN `answer_of_questions` AS ANSWERS_TABLE
ON QUESTIONS_TABLE.ID = ANSWERS_TABLE.QuestionID AND (ANSWERS_TABLE.Date_ID = $Day_ID AND ANSWERS_TABLE.User_ID = $User_ID)
";
$ExceuteAboveQuery = mysqli_query($DB, $SelectQuery);
foreach ($ExceuteAboveQuery as $Question) {
?>
<tr>
<?php if ($Question['ANSWER'] == NULL) : ?>
<form action="" method="POST">
<td> <label for="AnswerIN"> <?php echo $Question['QUESTION_COL'] ?> </label> </td>
<td> <textarea placeholder="Enter Answer Here" class="form-control" type="text" name="AnswerIN"> </textarea> </td>
<input hidden type="text" name="QuestionID" value="<?php echo $Question['QUESTION_ID'] ?>">
<td><button type="submit" name="AnswerBTN" class="btn btn-primary text-center col-md">Add Answer</button> </td>
</form>
<?php endif ?>
</tr>
<?php } ?>
</table>
</body>
</html>