-
Notifications
You must be signed in to change notification settings - Fork 1
/
notesubmit.php
executable file
·30 lines (22 loc) · 1.26 KB
/
notesubmit.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
<?php
// Initialize the session
session_start();
// Check if the user is logged in, otherwise redirect to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: ../login.php"); exit; }
if($username&&$note) {
$username = $_SESSION["username"];
$note = $_POST["note"];
require_once "../config.php";
//prepare sql statement
$query= $conn->prepare("INSERT INTO snotes (note,ownedby) VALUES (:note, :ownedby)");
//bind values
$query-> bindValue(':note', $note, PDO::PARAM_STR);
$query-> bindValue(':ownedby', $_SESSION['username'], PDO::PARAM_STR);
//execute
$query-> execute();
}
else {
echo "Username or note is missing";
}
?>