-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodify.php
More file actions
50 lines (38 loc) · 1.25 KB
/
Copy pathmodify.php
File metadata and controls
50 lines (38 loc) · 1.25 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
<?php
require_once 'read.php';
session_start();
if (isset($_GET['ModLnk']))
{
fillFields($_GET['ModLnk']);
}
if (isset($_POST['SaveBtn']))
{
header('location: index.php');
modifyTask($_POST['RowNumber']);
}
function fillFields($rowNumber)
{
require_once 'connection.php';
$db = mysqli_connect($host, $user, $password, $database);
$query = "SELECT * FROM `tasks` WHERE Id = " . $rowNumber;
$result = mysqli_fetch_assoc(mysqli_query($db, $query));
mysqli_close($db);
echo '<form action="modify.php" method="post">
<input type="hidden" name="RowNumber" value="' . $rowNumber . '">
<input type="date" name="Date" value="' . date("Y-m-d", (int)$result['DeadLine']) . '">
<input type="text" name="Task" value="' . $result['Task'] . '">
<input name="SaveBtn" value="Сохранить" type="submit">
</form>';
}
function modifyTask($rowNumber)
{
require_once 'connection.php';
$db = mysqli_connect($host, $user, $password, $database);
$query = "UPDATE `tasks`
SET DeadLine = " . strtotime($_POST['Date']) . ",
Task = '" . $_POST['Task'] . "'
WHERE Id = " . $rowNumber;
mysqli_query($db, $query);
mysqli_close($db);
updateTask();
}