-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateTask.php
More file actions
90 lines (73 loc) · 3.62 KB
/
updateTask.php
File metadata and controls
90 lines (73 loc) · 3.62 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
<!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">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<title>Update</title>
</head>
<body>
<?php
$conn = mysqli_connect(
"localhost",
"root",
"",
"vivek"
);
?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
$task_id = $_GET['id'];
$query = "select * from task where id=".$task_id.";";
$result = mysqli_query($conn, $query) or die('Query unsuccessful !');
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_assoc($result))
{
?>
<div class="container">
<div class="row mt-5 rounded bg-light border shadow-sm p-4 col-md-6">
<form method="POST" action="./updateTask.php">
<div class="form-group mt-2">
<input name="id" value="<?php echo $row['id']; ?>" class="form-control" id="id" aria-describedby="textHelp" hidden>
</div>
<div class="form-group mt-2">
<label for="id">Title</label>
<input name="title" value="<?php echo $row['title']; ?>" class="form-control" id="title" aria-describedby="textHelp">
</div>
<div class="form-group mt-2">
<label for="name">Remind at</label>
<input type="date" min="<?php echo date('Y-m-d') ?>" name="reminder" value="<?php echo $row['reminder']; ?>" class="form-control" id="reminder" aria-describedby="textHelp">
</div>
<div class="form-group mt-2">
<label for="descreption">Note</label>
<textarea name="note" class="form-control" id="note" rows="5"><?php echo $row['note']; ?></textarea>
</div>
<button type="submit" class="btn btn-primary m-3">UPDATE</button>
<a href="./" class=" mt-3 btn btn-outline-primary" style="display:inline">Back</a>
</form>
</div>
</div>
<?php
}}}
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$task_id = $_POST['id'];
$title = $_POST['title'];
$reminder = $_POST['reminder'];
$note = $_POST['note'];
$update_query = "update task set title='{$title}', reminder='{$reminder}', note='{$note}' where id={$task_id}";
$result = mysqli_query($conn, $update_query) or die('<script>alert("Database Insertion Error.")</script>');
echo ('<script>alert("Updated Successfully !")</script>');
header("Location: http://localhost/vivek/index.php");
}
mysqli_close($conn);
?>
<script src="js/jquery.js"></script>
<script src="js/popper.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>