74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
include 'koneksi.php';
|
|
|
|
session_start();
|
|
|
|
// Cek apakah user sudah login
|
|
if (!isset($_SESSION['username'])) {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
// Ambil data session
|
|
$username = $_SESSION['username'];
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['time1']) && isset($_POST['time2'])) {
|
|
$time1 = $_POST['time1'];
|
|
$time2 = $_POST['time2'];
|
|
|
|
// Insert or update feed times
|
|
$sql = "UPDATE feed_times SET time1='$time1', time2='$time2'";
|
|
|
|
if ($conn->query($sql) === TRUE) {
|
|
echo "<script>alert('Feed times have been saved!');</script>";
|
|
} else {
|
|
echo "<script>alert('Error!');</script>";
|
|
}
|
|
}
|
|
|
|
$conn->close();
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Pengaturan Waktu Pakan Ikan</title>
|
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
padding: 20px;
|
|
}
|
|
|
|
.custom-container {
|
|
max-width: 600px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container custom-container">
|
|
<h1 class="mb-4 text-center">Pengaturan Waktu Pakan Ikan</h1>
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
|
<div class="form-group">
|
|
<label for="time1">Waktu Pakan 1:</label>
|
|
<input type="time" class="form-control" id="time1" name="time1" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="time2">Waktu Pakan 2:</label>
|
|
<input type="time" class="form-control" id="time2" name="time2" required>
|
|
</div>
|
|
<button type="submit" name="submit" class="btn btn-primary float-right">Set Waktu Pakan</button>
|
|
<div class="text-left mb-3">
|
|
<a href="logout.php" class="btn btn-danger">Logout</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Bootstrap JS CDN (Optional) -->
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
|
</body>
|
|
|
|
</html>
|