-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_notes.php
More file actions
29 lines (26 loc) · 1.32 KB
/
create_notes.php
File metadata and controls
29 lines (26 loc) · 1.32 KB
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
<?php
// Check if the note title and description are set
if (isset($_POST['noteTitle']) && isset($_POST['noteDesc'])){
// Get the note title and description from the POST request
$title = $_POST['noteTitle'];
$desc = $_POST['noteDesc'];
// Display an error message if the note title and description are empty
if (empty($title) || empty($desc))
echo '<div class="bg-red-200 my-2 p-1 border border-black rounded-md">
<p class="text-red-900 font-semibold">Note submission could not be completed as title and description were left blank.</p>
</div>';
else{
// Insert the note into the database
$sql = "INSERT INTO `notes` (Title, Description) VALUES ('$title', '$desc')";
$db_result = mysqli_query($conn, $sql);
if(!$db_result) // Display an error message if the note was not inserted into the database
echo '<div class="bg-red-200 my-2 p-1 border border-black rounded-md">
<p class="text-red-900 font-semibold">Note submission failed because : '.mysqli_error($conn).'</p>
</div>';
else // Display a success message if the note was inserted into the database
echo '<div class="bg-green-200 my-2 p-1 border border-black rounded-md">
<p class="text-green-900 font-semibold">Note submitted successfully!</p>
</div>';
}
}
?>