-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
32 lines (28 loc) · 956 Bytes
/
edit.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
<?php
include('connection.php');
session_start();
if (isset($_SESSION['user_id'])) {
$userid = $_SESSION['user_id'];
try {
$conn = new PDO("mysql:host=$servername;dbname=$databasename", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "SELECT * FROM RakiFlipkart WHERE ID = :userid";
$obj = $conn->prepare($query);
$obj->bindParam(':userid', $userid);
$obj->execute();
$userData = $obj->fetch(PDO::FETCH_ASSOC);
if ($userData) {
$_SESSION['user_Data'] = $userData;
echo json_encode($userData);
} else {
echo json_encode(array('error' => 'User data not found.'));
}
} catch (PDOException $e) {
echo json_encode(["error" => "Error: " . $e->getMessage()]);
} finally {
$conn = null;
}
} else {
echo json_encode(["error" => "User not logged in"]);
}
?>