-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
85 lines (77 loc) · 1.95 KB
/
Copy pathprofile.php
File metadata and controls
85 lines (77 loc) · 1.95 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
header('Location: index.html');
exit;
}
$msg = '';
if (isset($_SESSION['msg'])) {
$msg = $_SESSION['msg'];
$_SESSION['msg'] = '';
}
include 'functions.php';
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'root';
$DATABASE_PASS = '';
$DATABASE_NAME = 'phppoll';
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if (mysqli_connect_errno()) {
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$stmt = $con->prepare('SELECT name, username, password, email, npm, prodi FROM accounts WHERE id = ?');
// pake id nya
$stmt->bind_param('i', $_SESSION['id']);
$stmt->execute();
$stmt->bind_result($name, $username, $password, $email, $npm, $prodi);
$stmt->fetch();
$stmt->close();
$stmt = $con->prepare('SELECT id FROM polls WHERE creator_id = ?');
$stmt->bind_param('i', $_SESSION['id']);
$stmt->execute();
$stmt->store_result();
$poll_count = $stmt->num_rows;
?>
<?=template_header('Profile')?>
<div class="container-fluid content">
<h2><i class="fa fa-user-circle fa-lg" style="margin-right: 10px;"></i>Profile Page</h2>
<?php
if ($msg != '') {
echo '<p>'. $msg .'</p>';
}
?>
<div>
<p>Your account details are below:</p>
<table class="table table-bordered">
<tr>
<td scope="col">Nama Lengkap:</td>
<td><?=$name?></td>
</tr>
<tr>
<td scope="col">NPM:</td>
<td><?=$npm?></td>
</tr>
<tr>
<td scope="col">Prodi:</td>
<td><?=$prodi?></td>
</tr>
<tr>
<td scope="col">Username:</td>
<td><?=$username?></td>
</tr>
<tr>
<td scope="col">Email:</td>
<td><?=$email?></td>
</tr>
<tr>
<td scope="col">IP address:</td>
<td><?=$_SESSION['ip']?></td>
</tr>
<tr>
<td scope="col">Poll created:</td>
<td><?=$poll_count?></td>
</tr>
</table>
<a href="edit_profile.php?id=<?=$_SESSION['id']?>" class="btn btn-info">Edit Profile</a>
</div>
</div>
<?=template_footer()?>