// Connect to the MySQL database $con = mysqli_connect("localhost", "username", "password", "db_name"); // Obtain customer and order information $name = $_POST['name']; $email = $_POST['email']; $item = $_POST['item']; $price = $_POST['price']; // Insert the order information into the database $query = "INSERT INTO orders (name, email, item, price) VALUES ('$name', '$email', '$item', '$price')"; mysqli_query($con, $query); // Close the database connection mysqli_close($con);
// Create a new order model instance $order = new Order(); // Obtain customer and order information $order->name = $_POST['name']; $order->email = $_POST['email']; $order->item = $_POST['item']; $order->price = $_POST['price']; // Save the order to the database $order->save();In this example, the Order model represents an "orders" database table and provides an easy way to write order information to the database. The PHP ActiveRecord library handles the database interactions behind the scenes, making it a convenient option for writing orders in PHP.