-
Notifications
You must be signed in to change notification settings - Fork 0
/
addtask.php
59 lines (54 loc) · 1.61 KB
/
addtask.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
51
52
53
54
55
56
57
58
59
<?php
$host = "localhost";
$database = "diary";
$user = "root";
$password = "";
$errors ="";
$connection = mysqli_connect($host,$user,$password,$database);
session_start();
if(!isset($_SESSION["loggedin"])){
header("location: index.html");
exit;
}
if(isset($_POST["addbutton"]))
{
if(!empty($_POST["date"]) and !empty($_POST["taskdes"]))
{
$task = $_POST["date"];
$desc = $_POST["taskdes"];
$insertsql = "INSERT INTO `tasks` ( `date`, `description`) VALUES ( '$task', '$desc');";
if(mysqli_query($connection,$insertsql)){
echo "<script>alert('Task added');</script>";
}
else{
echo "error ".mysqli_error($connection);
}
}
else{
$errors = "Fill in both fields";
}
}
mysqli_close($connection);
?>
<!DOCTYPE>
<html lang="en">
<head>
<title>Virtual Diary</title>
</head>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<link rel="stylesheet" href="css/options.css">
<body style="background:url(image.jpg); background-repeat:no-repeat;background-size:100% 100%">
<a href="../diary/main.php" class="home"><i class="fas fa-home"></i></a>
<div class="loginform">
<h2 >ADD EVENT</h2>
<form action="addtask.php" method="POST">
<input name="date" class="element" type="text" placeholder="Date"><br>
<input name="taskdes" class="description" type="text" placeholder="Entry..."><br>
<?php if (isset($errors)) { ?>
<p><?php echo $errors; ?></p>
<?php } ?>
<button id="button" name="addbutton" class="button">ADD</button>
</form>
</div>
</body>
</html>