-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyprofile.php
More file actions
59 lines (59 loc) · 1.53 KB
/
Copy pathmyprofile.php
File metadata and controls
59 lines (59 loc) · 1.53 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
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
<?php
require "includes/header.php";
$userid = $_SESSION['userid'];
// CONNECT TO DATABASE
include 'includes/library.php';
$pdo = connectdb();
// RETRIEVE USER CREDITIONALS
$query = "SELECT * FROM `signup_users` WHERE userid=?";
$stmt = $pdo->prepare($query);
$stmt->execute([$userid]);
$results = $stmt->fetch();
// RETREIVE PROFILE PICTURE
$src = $results['profilePic'];
// POST SUBMIT
if (isset($_POST['edit'])) {
header("Location: editprofile.php");
exit();
} else if (isset($_POST['delete'])) {
$query= "DELETE FROM `signup_users` WHERE userid=?";
$stmt = $pdo->prepare($query)->execute([$userid]);
header("Location: logout.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php $page_title = "My Profile"; ?>
<?php include "includes/metadata.php" ?>
</head>
<body>
<section class="myProfile">
<form method="POST">
<h2>My Profile</h2>
<div>
<p>Profile Picture</p>
<img src="<?=$src?>" alt="Profile Pic" />
</div>
<div>
<p>Username</p>
<p><?php echo $results['username']; ?></p>
</div>
<div>
<p>Email</p>
<p><?php echo $results['email']; ?></p>
</div>
<div>
<p>Password</p>
<p><?php echo "********";?></p>
</div>
<div>
<button type="submit" name="edit">Edit Profile</button>
<button type="submit" name="delete">Delete Account</button>
</div>
</form>
</section>
<?php include "includes/footer.php" ?>
</body>
</html>