-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddTodo.php
More file actions
26 lines (25 loc) · 925 Bytes
/
addTodo.php
File metadata and controls
26 lines (25 loc) · 925 Bytes
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
<?php
require "./includes/head.php";
if(isset($_POST["submit"])){
$sql = "INSERT INTO posts (title, text) VALUES ('{$_POST['title']}', '{$_POST['text']}')";
if($db_conn-> query($sql) === TRUE){
header("Location: ./index.php?msg=success");
}else{
echo "Error:".$sql."<br>".$db_conn->error;
}
}
?>
<h1 class="m-4">Add Todo</h1>
<form action="./addTodo.php" method="POST" class="m-4">
<div class="form-group">
<label for="title" class="form-label">Title: </label>
<input type="text" name="title" class="form-control" id="title" placeholder="Study" required>
</div>
<div class="form-group">
<label for="text" class="form-label">Text: </label>
<textarea class="form-control" id="text" rows="3" name="text" required>
</textarea>
</div>
<input type="submit" name="submit" class="btn btn-info mt-5" value="Save">
</form>
<?php require "./includes/footer.php" ?>