-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
50 lines (46 loc) · 1.43 KB
/
edit.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
<?php
include("db.php");
$title = '';
$description= '';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT * FROM task WHERE id=$id";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_array($result);
$title = $row['title'];
$description = $row['description'];
}
}
if (isset($_POST['update'])) {
$id = $_GET['id'];
$title= $_POST['title'];
$description = $_POST['description'];
$query = "UPDATE task set title = '$title', description = '$description' WHERE id=$id";
mysqli_query($conn, $query);
$_SESSION['message'] = 'Actualizado satisfactoriamente';
$_SESSION['message_type'] = 'warning';
header('Location: index.php');
}
?>
<?php include('includes/header.php'); ?>
<div class="container p-4">
<div class="row">
<div class="col-md-4 mx-auto">
<div class="card card-body">
<form action="edit.php?id=<?php echo $_GET['id']; ?>" method="POST">
<div class="form-group">
<input name="title" type="text" class="form-control" value="<?php echo $title; ?>" placeholder="Update Title">
</div>
<div class="form-group">
<textarea name="description" class="form-control" cols="30" rows="10"><?php echo $description;?></textarea>
</div>
<button class="btn-success" name="update">
Update
</button>
</form>
</div>
</div>
</div>
</div>
<?php include('includes/footer.php'); ?>