Gabaclowell

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

<!

DOCTYPE html>

<html>

<head>

<title>Activity Log</title>

<link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

<div class="container">

<h1>Activity Log</h1>

<table>

<tr>

<th>Timestamp</th>

<th>Action</th>

</tr>

<?php

// Database connection

$conn = mysqli_connect("localhost", "root", "root", "gabaclowell_db");

// Check connection

if (!$conn) {

die("Connection failed: " . mysqli_connect_error());

// Get action from form

$action = $_POST["action"];

// Insert new action into database

if(!empty($action)) {

$sql = "INSERT INTO activity_log (timestamp, action) VALUES (NOW(), '$action')";


mysqli_query($conn, $sql);

// Select data from database

$sql = "SELECT * FROM activity_log ORDER BY timestamp DESC";

$result = mysqli_query($conn, $sql);

// Display data in table

if (mysqli_num_rows($result) > 0) {

while($row = mysqli_fetch_assoc($result)) {

echo "<tr><td>" . $row["timestamp"] . "</td><td>" . $row["action"] . "</td></tr>";

} else {

echo "<tr><td colspan='2'>No activity logged.</td></tr>";

mysqli_close($conn);

?>

<form method="post" action="">

<tr>

<td><strong>Current Time:</strong></td>

<td><?php echo date("Y-m-d H:i:s"); ?></td>

</tr>

<tr>

<td><strong>Action:</strong></td>

<td><input type="text" name="action"></td>

</tr>

<tr>

<td colspan="2"><input type="submit" value="Add Action"></td>


</tr>

</form>

</table>

</div>

</body>

</html>

/* styles.css */

/* Body styles */

body {

font-family: Arial, sans-serif;

margin: 0;

padding: 0;

background-color: #f2f2f2;

/* Container styles */

.container {

max-width: 800px;

margin: 0 auto;

padding: 20px;

background-color: #fff;

box-shadow: 0 2px 4px rgba(0,0,0,.1);

/* Heading styles */

h1 {
font-size: 36px;

font-weight: bold;

margin-top: 0;

/* Table styles */

table {

border-collapse: collapse;

width: 100%;

th, td {

text-align: left;

padding: 8px;

th {

background-color: #eee;

font-weight: bold;

tr:nth-child(even) {

background-color: #f2f2f2;

/* Form styles */

form {

margin-top: 20px;

}
label {

display: block;

margin-bottom: 8px;

input[type="text"] {

width: 100%;

padding: 8px;

border-radius: 4px;

border: none;

box-shadow: inset 0 2px 2px rgba(0,0,0,.1);

button[type="submit"] {

background-color: #4CAF50;

color: #fff;

border: none;

border-radius: 4px;

padding: 8px 16px;

cursor: pointer;

font-size: 16px;

transition: background-color .3s ease;

button[type="submit"]:hover {

background-color: #3e8e41;

You might also like