Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Simple Sales Input</title> </head> <body> <h2>Simple Sales Input</h2> <?php // Process the form data when the form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get input values $productName = $_POST["product_name"]; $quantity = $_POST["quantity"]; $price = $_POST["price"]; // Calculate total sales amount $totalAmount = $quantity * $price; // Display results echo "<p>Product Name: $productName</p>"; echo "<p>Quantity: $quantity</p>"; echo "<p>Price per unit: $price</p>"; echo "<p>Total Amount: $totalAmount</p>"; } ?> <!-- Sales Input Form --> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"> <label for="product_name">Product Name:</label> <input type="text" name="product_name" required><br> <label for="quantity">Quantity:</label> <input type="number" name="quantity" required><br> <label for="price">Price per unit:</label> <input type="number" step="0.01" name="price" required><br> <input type="submit" value="Calculate"> </form> </body> </html>
Copy Clear