0

I am trying to create a prepared statement based on the user input and save it to the database, but it seems to fail when it is excuted:
Here is my code. Does anyone know what is wrong with my code

  <?php
session_start();
require_once 'conn.php';
if($_GET['orderform']){
 if($_GET['username'] and $_GET['time'] and $_GET['quantity'] and $_GET['image'] and $_GET['uprice']){
$x = $_GET['uprice'];
$y = $_GET['quantity'];
$total = $x*$y;
$userid = $_SESSION[id];
$username = $_GET['username'];
$quantity = $_GET['quantity'];
$time = $_GET['time'];
$image = $_GET['image'];
$uprice = $_GET['uprice'];        
   
$stm=$query=$conn = "INSERT INTO `orders` (userid, username, quantity, timee, image, uprice, tprice) VALUES(:userid, :username, :quantity, :timee, :image, :uprice, :tprice)";
$stmt = $conn->prepare($stm);
$stmt->bindParam(':userid', $userid);
$stmt->bindParam(':username', $username);
$stmt->bindParam(':quantity', $quantity);
$stmt->bindParam(':timee', $time);
$stmt->bindParam(':image', $image);
$stmt->bindParam(':uprice', $uprice);
$stmt->bindParam(':tprice', $total);
$stmt->execute();
 if($stmt->execute()){
   
   header('location: index.php');}

 

}
}


?>
Monolica
  • 115
  • 7

0 Answers0