-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
45 lines (40 loc) · 1.51 KB
/
update.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
<!DOCTYPE html>
<?php include 'db.php';
$id = (int)$_GET['id'];
$sql = "select * from tasks where id='$id'";
$rows = $db->query($sql);
$row = $rows->fetch_assoc();
if(isset($_POST['send'])){
$task = htmlspecialchars($_POST['task']);
$sql2 ="update tasks set name='$task' where id ='$id'";
$db->query($sql2);
header('location: index.php');
}
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Crud App</title>
</head>
<body>
<div class="container">
<center><h1>Update Todo list</h1></center>
<div class="row" style="margin-top: 70px;">
<div class="col-md-10 col-md-offset-1" >
<table class="table">
<hr><br>
<form method="post" >
<div class="form-group">
<label>Task Name</label>
<input type="text" required name="task" value="<?php echo $row['name'];?>" class="form-control">
</div>
<input type="submit" name="send" value="Add Task" class="btn btn-success">
<a href="index.php" class="btn btn-warning">Back</a>
</form>
</div>
</div>
</div>
</body>
</html>