Server : Apache System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64 User : nobody ( 99) PHP Version : 8.1.23 Disable Function : NONE Directory : /home/dnlcambodia/public_html/dnl_dashboard/Feature/Process/ |
<?php // Check if the form was submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check if all required fields are filled if (!empty($_POST['name']) && !empty($_POST['description'])) { // Sanitize the input data to prevent SQL injection $name = htmlspecialchars($_POST['name']); $description = htmlspecialchars($_POST['description']); // Perform database operation to insert the data include '../PHP/config/db_conn.php'; // Prepare and bind the INSERT statement $stmt = $conn->prepare("INSERT INTO feature (name, description) VALUES (?, ?)"); $stmt->bind_param("ss", $name, $description); // Execute the statement if ($stmt->execute()) { echo "Record inserted successfully."; } else { echo "Error: " . $stmt->error; } // Close the statement and connection $stmt->close(); $conn->close(); } else { echo "Please fill all required fields."; } }