-
Notifications
You must be signed in to change notification settings - Fork 55
/
profile.php
51 lines (48 loc) · 2 KB
/
profile.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
session_start();
if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin'] == true) {
header('location: /login.php');
die();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!isset($_POST['description'])) {
$error = true;
}
else {
$description = $_POST['description'];
include('includes/db_connect.php');
$ret = pg_prepare($db, "updatedescription_query", "update users set description = $1 where username = $2");
$ret = pg_execute($db, "updatedescription_query", Array($description, $_SESSION['username']));
$success = true;
}
}
?>
<html>
<head>
<title>TUDO/My Profile</title>
<link rel="stylesheet" href="style/style.css">
</head>
<body>
<?php include('includes/header.php'); ?>
<div id="content">
<?php
include('includes/db_connect.php');
$ret = pg_prepare($db, "selectprofile_query", "select * from users where username = $1;");
$ret = pg_execute($db, "selectprofile_query", Array($_SESSION['username']));
$row = pg_fetch_row($ret);
?>
<h1>My Profile:</h1>
<form action="profile.php" method="POST">
<label for="username">Username: </label>
<input name="username" value="<?php echo $row[1]; ?>" disabled><br><br>
<label for="password">Password: </label>
<input name="password" value="<?php echo $row[2]; ?>" disabled><br><br>
<label for="description">Description: </label>
<input name="description" value="<?php echo $row[3]; ?>"><br><br>
<input type="submit" value="Update">
<?php if (isset($error)) {echo '<span style="color:red">Error</span>';}
else if (isset($success)) {echo '<span style="color:green">Success</span>';} ?>
</form>
</div>
</body>
</html>