WT assignment 2
WT assignment 2
<?php
include 'db_config.php';
session_start();
$stmt->close();
}
?>
REGISTER
<?php
include 'db_config.php';
$stmt = $conn->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $name, $email, $password);
if ($stmt->execute()) {
echo "Registra on successful! <a href='login.php'>Login here</a>";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
}
?>
DASHBOARD
<?php
include 'db_config.php';
session_start();
if (!isset($_SESSION['user_id'])) {
header("Loca on: login.php");
exit();
}
$user_id = $_SESSION['user_id'];
if ($stmt->execute()) {
echo "Book added successfully!";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
}
if ($stmt->execute()) {
echo "Book removed successfully!";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, ini al-scale=1.0">
< tle>Book Exchange Club</ tle>
<!-- Link to CSS file -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>Welcome to the Book Exchange Club</h2>
<hr>
<!-- User's Books -->
<h3>Your Added Books</h3>
<table border="1">
<tr>
<th>Title</th>
<th>Author</th>
<th>Genre</th>
<th>Condi on</th>
<th>Ac on</th>
</tr>
<?php while ($row = $user_books->fetch_assoc()): ?>
<tr>
<td><?php echo $row[' tle']; ?></td>
<td><?php echo $row['author']; ?></td>
<td><?php echo $row['genre']; ?></td>
<td><?php echo $row['condi on']; ?></td>
<td>
<form method="POST" style="display:inline;">
<input type="hidden" name="book_id" value="<?php echo $row['id']; ?>">
<bu on type="submit" name="delete_book">Remove</bu on>
</tr>
<?php endwhile; ?>
</table>
<hr>
</tr>
<?php endwhile; ?>
</table>
</div>
</body>
</html>