-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote_update.php
More file actions
32 lines (28 loc) · 855 Bytes
/
note_update.php
File metadata and controls
32 lines (28 loc) · 855 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
27
28
29
30
31
32
<?php
// Start session
session_start();
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: index.html");
exit();
}
// Include database connection file
include_once "db_connection.php";
$userid = $_SESSION['user_id'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Collect form data
$body = $_POST['note'];
$title = $_POST['title'];
$idc=$_POST['hide'];
echo $id;
// update user data from database
$sql = "UPDATE notes SET title='$title', body='$body' WHERE id = (SELECT id FROM (SELECT id FROM notes ORDER BY id LIMIT 1 OFFSET $idc) AS subquery) AND userid='$userid'";
if (mysqli_query($conn, $sql)) {
header("Location: profile.php");
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
}
?>