-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_task.php
More file actions
130 lines (130 loc) · 4.44 KB
/
Copy pathadd_task.php
File metadata and controls
130 lines (130 loc) · 4.44 KB
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
<?php
session_start();
if (!isset($_SESSION['user_id']))
{
header('Location: index.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Task</title>
<link rel="stylesheet" href="./css/Uprofile.css">
</head>
<body>
<span class="heada1">Add Task</span>
<span class="heada2"><?php echo $_SESSION['funame']?> <?php echo $_SESSION['luname']?> </span>
<?php
if ($_SESSION['role'] === 'Admin')
{
echo '<a href="admindashboard.php" class="backlink">Back to Profile</a>';
}
else if ($_SESSION['role'] === 'User')
{
echo '<a href="profile.php" class="backlink">Back to Profile</a>';
}
?>
<div class="pagetask zoom">
<form class="formm" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<label for="addtask" class="lab">Add Task Name:</label>
<input class="inpt" type="text" id="addtask" name="addtask" value="<?php if(isset($_POST['addtask'])) {echo $_POST['addtask'];} ?>" autofocus>
<label for="taskday" class="lab">Task Day:</label>
<input class="inpt" type="date" id="taskday" name="taskday" value="<?php if(isset($_POST['taskday'])) {echo $_POST['taskday'];} ?>">
<label for="tasktime" class="lab">Task Time In Minutes:</label>
<input class="inpt" type="text" id="tasktime" name="tasktime" value="<?php if(isset($_POST['tasktime'])) {echo $_POST['tasktime'];} ?>">
<input type="submit" class="subt" value="Add Task">
</form>
</div>
<?php
require_once 'connect.php';
$Countererror = 0;
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$addtaskk = $_POST['addtask'];
$pattern = '/^[A-Za-z0-9\s]+$/';
if(empty($addtaskk) || !preg_match($pattern, $addtaskk))
{
echo "
<h3 style='position:absolute; top: 39%; left: 58%; color: #EFC176' id='addtaskkk'>
Task Name Faild!..Please Enter Letters OR Number Only.
</h3>";
echo "<script>
setTimeout ( function() {
addtaskkk.innerHTML = '';
} , 3000);
</script>";
$Countererror++;
}
if(empty($_POST['taskday']))
{
echo "<h3 style='position:absolute; top: 53%; left: 58%; color: #EFC176' id='dat'>
Please Select Your Correct Date Of Birth.
</h3>";
echo "<script>
setTimeout ( function() {
dat.innerHTML = '';
} , 3000);
</script>";
$Countererror++;
}
$taskktime = $_POST['tasktime'];
$pattern = '/^[0-9]+$/';
if(empty($taskktime) || !preg_match($pattern, $taskktime) || strlen($taskktime) > 3)
{
echo "
<h3 style='position:absolute; top: 68%; left: 58%; color: #EFC176' id='taskkktime'>
Task Time Faild!..Please Enter Correct Minutes Less Than 999 .
</h3>";
echo "<script>
setTimeout ( function() {
taskkktime.innerHTML = '';
} , 3000);
</script>";
$Countererror++;
}
if(isset($addtaskk)
&& isset($_POST['taskday'])
&& isset($taskktime)
&& $Countererror == 0)
{
$Query4 = 'insert into task (tname,tdate,ttime,idu) values(:a,:b,:c,:d)';
$statmen4 = $conn->prepare($Query4);
$statmen4->execute(array(
':a'=>$addtaskk,
':b'=>$_POST['taskday'],
':c'=>$taskktime,
':d'=>$_SESSION['user_id']
)
);
echo "<h1 style='position:absolute; top: 50%; left: 60%; color:#EFC176' id='succ'>
The task has been added successfully...
</h1>";
if ($_SESSION['role'] === 'Admin')
{
echo '<script>
setTimeout ( function() {
succ.innerHTML = "";
} , 3000);
setTimeout(function() {
window.location.href = "admindashboard.php";
}, 3000);
</script>';
}
else if ($_SESSION['role'] === 'User')
{
echo '<script>
setTimeout ( function() {
succ.innerHTML = "";
} , 3000);
setTimeout(function() {
window.location.href = "profile.php";
}, 3000);
</script>';
}
}
}
?>
</body>
</html>