SESSION method POST отправка заказа пользователя в базу данных

db connect

$db = new PDO('mysql:host=localhost; dbname=bereket; cahrset=utf8;', 'root', 'root' );


$stmt = $db->prepare("INSERT INTO order_details (address, title, quantity, total_price) 
VALUES (:address, :title, :quantity, :total_price)");

$stmt ->bindParam(':address', $_POST["address"]);
$stmt ->bindParam(':title', $_POST["title"]);
$stmt ->bindParam(':quantity', $_POST["quantity"]);
$stmt ->bindParam(':total_price', $_POST["total_price"]);
    

order.html

if($stmt->execute()){
    echo "YEs";
    // header("Location: admin-success.php");

}else {
    echo"Вы еще не добавили товара";
}

    if(!empty($_SESSION["shopping_cart"]))
        {
            
            $total = 0;
            
            foreach($_SESSION['shopping_cart'] as $keys => $values)
            {   for ($i=0; $i<count($_SESSION))
                
        ?>
            <form  action="component.php" method="POST" >
                        <div class="form-group">
                        <label for="address">Address</label>
                            <input  name = "address" id="address" type="text" class="form-control field-style field-split" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="City">
                        </div>
                        <div class="form-group">
                        <label for="title">Title</label>
                            <input  name = "title" id="title" type="text" class="form-control field-style field-split" id="exampleInputEmail1" aria-describedby="emailHelp" 
                            value="<?php echo $values["title"]; ?>">
                        </div>
                        <div class="form-group">
                            <input  name = "quantity" type="text" class="form-control field-style field-split" id="exampleInputEmail1" aria-describedby="emailHelp" value="<?php echo $values["quantity"]; ?>">
                        </div>
                        <?php
                            $total = $total + ($values["quantity"] * $values["price"]);
                        };
                    ?>
                        <div class="form-group">
                            <input  name = "total_price" type="text" class="form-control field-style field-split" id="exampleInputEmail1" aria-describedby="emailHelp" value="<?php echo number_format($total, 0); ?>">
                        </div>
                      <?php
                
                }

Ответы (0 шт):