403Webshell
Server IP : 173.209.174.21  /  Your IP : 216.73.216.89
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : nodor ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/thelittlebigshow/self-hosted/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thelittlebigshow/self-hosted/new_transaction.php
<?php include 'protect.php'; ?>

<?php
// db.php � include this file for DB connection
include 'db.php';

// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $customer_id = $_POST['customer_id'];
    $item_name = $_POST['item_name'];
    $price = $_POST['price'];
    $quantity = $_POST['quantity'];
    $taxable = isset($_POST['taxable']) ? 1 : 0;

    // Optional: insert new item if not already in items table
    $check = $conn->prepare("SELECT id FROM items WHERE name = ?");
    $check->bind_param("s", $item_name);
    $check->execute();
    $check->store_result();
    if ($check->num_rows == 0) {
        $insert_item = $conn->prepare("INSERT INTO items (name, price) VALUES (?, ?)");
        $insert_item->bind_param("sd", $item_name, $price);
        $insert_item->execute();
    }

    $stmt = $conn->prepare("INSERT INTO transactions (customer_id, item_name, price, quantity, taxable) VALUES (?, ?, ?, ?, ?)");
    $stmt->bind_param("issdi", $customer_id, $item_name, $price, $quantity, $taxable);
    $stmt->execute();
    echo "Transaction saved!";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>New Transaction</title>
    <script>
    async function autofillPrice() {
        const name = document.getElementById("item_name").value;
        const response = await fetch("get_item_price.php?name=" + encodeURIComponent(name));
        const data = await response.json();
        if (data.found) {
            document.getElementById("price").value = data.price;
        }
    }
    </script>
</head>
<body>
<h2>Add New Transaction</h2>
<form method="post">
    <label for="customer_id">Customer:</label>
    <select name="customer_id" required>
        <?php
        $result = $conn->query("SELECT id, name FROM customers ORDER BY name");
        while ($row = $result->fetch_assoc()) {
            echo "<option value='{$row['id']}'>{$row['name']}</option>";
        }
        ?>
    </select><br><br>

    <label for="item_name">Item:</label>
    <input type="text" id="item_name" name="item_name" onblur="autofillPrice()" required><br><br>

    <label for="price">Price:</label>
    <input type="number" id="price" step="0.01" name="price" required><br><br>

    <label for="quantity">Quantity:</label>
    <input type="number" name="quantity" value="1" required><br><br>

    <label><input type="checkbox" name="taxable" checked> Taxable</label><br><br>

    <button type="submit">Save</button>
</form>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit