summaryrefslogtreecommitdiff
path: root/user.php
diff options
context:
space:
mode:
Diffstat (limited to 'user.php')
-rw-r--r--user.php70
1 files changed, 26 insertions, 44 deletions
diff --git a/user.php b/user.php
index 62b9144..a5e1d16 100644
--- a/user.php
+++ b/user.php
@@ -1,56 +1,38 @@
<?php
-include_once 'header.php';
include_once 'includes/db_inc.php';
-include_once 'includes/functions_display.php';
-?>
-<?php
-function nobody_is_here() {
- echo 'Nobody\'s here! <a href=index.php>Go home.</a>';
-}
-
-if (!isset($_GET['id'])) {
- nobody_is_here();
-} else {
- // If this is the user's own page, show the 'options' bar
- echo '<section>';
+session_start();
- $sql = 'SELECT user_id, user_name, user_date FROM users WHERE user_id=?';
- $stmt = mysqli_stmt_init($dbc);
+$user_name = "Unknown";
+$user_date = 0;
- if (!mysqli_stmt_prepare($stmt, $sql)) {
- die('Could not create thread due to internal error: ' . mysqli_error($dbc));
- }
- mysqli_stmt_bind_param($stmt, 'i', $_GET['id']);
- mysqli_stmt_execute($stmt);
- $res = mysqli_stmt_get_result($stmt);
- $user = mysqli_fetch_assoc($res);
-
- if (!$user) {
- nobody_is_here();
- } else {
- echo '<div><h1>'. $user['user_name'] .'</h1></div>';
- echo 'Member since '. date('M d, Y', strtotime($user['user_date']));
- }
-
- if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $_GET['id']) {
- echo '<br><p><a href=change_passw.php>Change Password</a></p>';
- }
-
- echo '</section>';
-
- $sql = "SELECT thread_id, thread_subject, thread_date, user_id, user_name, cat_id, cat_name FROM threads JOIN users ON thread_author = user_id JOIN categories ON thread_cat = cat_id WHERE thread_author = " . $user['user_id'] . " ORDER BY thread_id DESC";
+if (!isset($_GET['name'])) {
+} else {
+ $sql = "SELECT user_date FROM users WHERE user_name = '" . $_GET['name'] . "'";
$result = mysqli_query($dbc, $sql);
if (!$result) {
- die('Error trying to display threads: ' . mysqli_error($dbc));
+ die('Error trying to display user page: ' . mysqli_error($dbc));
}
- echo '<table><tr><th class="left">' . $user['user_name'] . '\'s Threads</th><th class="right">Latest Post</th></tr>';
- display_threads($dbc, $result, true);
- mysqli_free_result($result);
- echo '</table>';
+ if (mysqli_num_rows($result) == 0) {
+ $user_name = "Unknown";
+ } else {
+ while ($row = mysqli_fetch_assoc($result)) {
+ $user_name = $_GET['name'];
+ $user_date = $row['user_date'];
+ }
+ }
}
?>
-
-<?php include_once 'footer.php'; ?>
+<!DOCTYPE html>
+<html>
+<head>
+ <title><?php echo $user_name; ?>'s Profile - cflip.net forum</title>
+</head>
+<body style="width: 720px;margin: auto;">
+ <?php include_once "templates/header.php" ?>
+ <h1><?php echo $user_name; ?></h1>
+ member since <?php echo $user_date; ?>
+</body>
+</html> \ No newline at end of file