One Hat Cyber Team
Your IP :
18.222.30.37
Server IP :
50.28.103.30
Server :
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
nginx/1.24.0
PHP Version :
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
sd.electronharmony.com
/
works
/
View File Name :
add_ws.php
<?php // Database connection details $servername = "localhost"; $username = "t001"; $password = "ZRTsRb6Ycp585AEC"; // Your database password $dbname = "t001"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Add employee and generate days with default status 'Off' function addEmployeeWithDays($conn, $employeeName) { // Insert the employee into the employees table $stmt = $conn->prepare("INSERT INTO employees (name) VALUES (?)"); $stmt->bind_param("s", $employeeName); $stmt->execute(); $employeeID = $conn->insert_id; // Get the newly created employee's ID // Get the total number of days in the current month $lastDay = date("t"); // Insert days with default status 'Off' $stmt = $conn->prepare("INSERT INTO employee_days (employee_id, day_of_month, status) VALUES (?, ?, 'v')"); for ($day = 1; $day <= $lastDay; $day++) { $stmt->bind_param("ii", $employeeID, $day); $stmt->execute(); } $stmt->close(); } // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['name'])) { $employeeName = htmlspecialchars($_POST['name']); // Sanitize user input addEmployeeWithDays($conn, $employeeName); echo '<div class="alert alert-success">Employee and daily records added successfully!</div>'; header("Location: ws.php"); } else { echo '<div class="alert alert-warning">Invalid form submission.</div>'; } // Close connection $conn->close(); ?>