-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.php
84 lines (62 loc) · 2.19 KB
/
notes.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require "partials/_dbConnect.php";
// Start the session
session_start();
if(!isset($_SESSION['loggedin']) || ($_SESSION['loggedin'] != true)){
header("location: login.php");
exit;
}
$name = $_SESSION['username'];
if($_SERVER["REQUEST_METHOD"] == "POST"){
$heading = $_POST["heading"];
$main = $_POST["main"];
$sqlInsert = "INSERT INTO `notes`(`name`, `heading`, `main`) VALUES ('$name', '$heading', '$main')";
$resultInsert = mysqli_query($conn, $sqlInsert);
}
// Displaying all notes
$allNSql = "SELECT * FROM `notes` WHERE name='$name'";
$allNResult = mysqli_query($conn, $allNSql);
?>
<html>
<head>
<title> Website | Notes |
<?php $_SESSION['username']?>
</title>
<link rel="stylesheet" href="partials/style.css">
</head>
<body>
<?php require "partials/_navbar.php" ?>
<section class="background">
<div class="addNotes">
<h2 class="heading"><u>
<?php echo $_SESSION['username']?>'s notes section
</u></h2>
<form action="notes.php" method="post" id="notes">
<label for="" class="labels">Title</label>
<input type="text" name="heading" id="title" class="userInput">
<label for="" class="labels">Description</label>
<textarea name="main" id="description" cols="30" rows="6 " class="userInput"></textarea>
<button type="submit" id="add"> Add </button>
</form>
</div>
</section>
<section id="displayNotes">
<h2 class="heading">Your Notes</h2>
<?php
foreach($allNResult as $i){
echo "
<div class='notesBody'>
<p class='notesTitle'>" . $i['heading'] . "</p>
<hr class='line'>
<p class='notesDesc'>" . $i['main'] . "</p>
<p class='notesDateTime'>" . $i['timestamp'] . "</p>
<div class='editDelete'>
<button class='edit'>Edit</button>
<button class='delete'>Delete</button>
</div>
</div>";
}
?>
</section>
</body>
</html>