You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.3 KiB
173 lines
4.3 KiB
<?php
|
|
// Start the session and check if the user is logged in
|
|
session_start();
|
|
|
|
// Check if the user is logged in
|
|
if (!isset($_SESSION["loggedInUser"])) {
|
|
header("Location: login.php"); // Redirect to login page if not logged in
|
|
exit();
|
|
}
|
|
|
|
// Database connection
|
|
$conn = new mysqli('localhost', 'root', '', 'user'); // Replace with your database credentials
|
|
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
// Get the logged-in user's email from the session
|
|
$email = $_SESSION["loggedInUser"];
|
|
|
|
// Create SQL query using prepared statements
|
|
$sql = "SELECT username, email, streak FROM registration WHERE email = ?";
|
|
$stmt = $conn->prepare($sql);
|
|
|
|
// Check if the statement was prepared successfully
|
|
if (!$stmt) {
|
|
die("SQL Error: " . $conn->error);
|
|
}
|
|
|
|
// Bind the parameter
|
|
$stmt->bind_param("s", $email);
|
|
|
|
// Execute the query
|
|
$stmt->execute();
|
|
|
|
// Get the result of the query
|
|
$result = $stmt->get_result();
|
|
|
|
// Check if the user exists
|
|
if ($result->num_rows > 0) {
|
|
// Fetch the user's data
|
|
$user = $result->fetch_assoc();
|
|
$userName = $user['username'];
|
|
$userEmail = $user['email'];
|
|
$userStreak = $user['streak'];
|
|
} else {
|
|
// If no user found, set default values
|
|
$userName = "Guest";
|
|
$userEmail = "Not Found";
|
|
$userStreak = 0;
|
|
}
|
|
|
|
// Close the statement and connection
|
|
$stmt->close();
|
|
$conn->close();
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="description" content="Welcome to our homepage. Explore our services, products, and more.">
|
|
<title>User Profile</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
header {
|
|
background-color: #007bff;
|
|
color: white;
|
|
padding: 1rem 2rem;
|
|
text-align: center;
|
|
}
|
|
nav {
|
|
display: flex;
|
|
justify-content: center;
|
|
background-color: #333;
|
|
}
|
|
nav a {
|
|
color: white;
|
|
text-decoration: none;
|
|
padding: 1rem;
|
|
margin: 0 0.5rem;
|
|
}
|
|
nav a:hover {
|
|
background-color: #575757;
|
|
border-radius: 5px;
|
|
}
|
|
main {
|
|
padding: 2rem;
|
|
}
|
|
footer {
|
|
background-color: #007bff;
|
|
color: white;
|
|
text-align: center;
|
|
padding: 1rem;
|
|
position: fixed;
|
|
bottom: 0;
|
|
width: 100%;
|
|
}
|
|
.profile-card {
|
|
width: 50%;
|
|
margin: 30px auto;
|
|
padding: 20px;
|
|
background-color: #f4f4f9;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.profile-card h2 {
|
|
text-align: center;
|
|
}
|
|
.profile-card p {
|
|
font-size: 18px;
|
|
color: #333;
|
|
}
|
|
.profile-card strong {
|
|
color: #007bff;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<h1>Welcome to Info Path</h1>
|
|
<p>Your one-stop destination for quality content and services.</p>
|
|
</header>
|
|
|
|
<nav>
|
|
<a href="homepage.php">Home</a>
|
|
<a href="about.html">About</a>
|
|
<a href="services.html">Services</a>
|
|
<a href="contact.html">Contact</a>
|
|
<a href="login.php">Log Out</a>
|
|
</nav>
|
|
|
|
<main>
|
|
<section id="home">
|
|
<h2>Home</h2>
|
|
<p>Explore our latest updates and featured content.</p>
|
|
</section>
|
|
<section id="about">
|
|
<h2>About</h2>
|
|
<p>Learn more about us.</p>
|
|
</section>
|
|
<section id="services">
|
|
<h2>Services</h2>
|
|
<p>Discover what we offer to meet your needs.</p>
|
|
</section>
|
|
<section id="contact">
|
|
<h2>Contact</h2>
|
|
<p>Get in touch with us for any inquiries.</p>
|
|
</section>
|
|
|
|
<!-- User Profile Section -->
|
|
<section id="profile">
|
|
<div class="profile-card">
|
|
<h2>User Profile</h2>
|
|
<p><strong>Name:</strong> <?php echo htmlspecialchars($userName); ?></p>
|
|
<p><strong>Email:</strong> <?php echo htmlspecialchars($userEmail); ?></p>
|
|
<p><strong>Streak:</strong> <?php echo htmlspecialchars($userStreak); ?></p>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
|
|
<footer>
|
|
<p>© 2025 Your Website Name. All Rights Reserved.</p>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|
|
|