SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. include 'included.php';
  4.  
  5. if (!empty($_POST)) {
  6.    
  7.     $valid = true;
  8.    
  9.     $name = $_GET['name'];
  10.     $price = $_GET['price'];
  11.     $description = $_GET['description'];
  12.     $sku = $_GET['sku'];
  13.     $img = $_GET['img'];
  14.     die($description);
  15.    
  16.     $query = $database_connection_pdo->prepare("INSERT INTO products(name,price,description,sku,img) VALUES(:name,:description,:sku,:img)");
  17.     $query->bindParam(":name", $name);
  18.     $query->bindParam(":price", $price);
  19.     $query->bindParam(":description", $description);
  20.     $query->bindParam(":sku", $sku);
  21.     $query->bindParam(":img", $img);
  22.     $query->execute();
  23.    
  24. }
  25.  
  26. ?>
  27.  
  28. <body>
  29.     <div class="container">
  30.         <form method="post">
  31.            
  32.           <div class="form-group row">
  33.             <label for="name" class="col-sm-2 col-form-label">Name</label>
  34.             <div class="col-sm-10">
  35.               <input name="name" class="form-control" id="name" placeholder="Name">
  36.             </div>
  37.           </div>
  38.          
  39.           <div class="form-group row">
  40.             <label for="price" class="col-sm-2 col-form-label">Price</label>
  41.             <div class="input-group col-sm-10">
  42.                 <div class="input-group-prepend">
  43.                   <div class="input-group-text">$</div>
  44.                 </div>
  45.               <input name="price" class="form-control" id="price" placeholder="Price">
  46.             </div>
  47.           </div>
  48.          
  49.          <div class="form-group row">
  50.             <label for="description" class="col-sm-2 col-form-label">Description</label>
  51.             <div class="col-sm-10">
  52.               <input name="description" class="form-control" id="description" placeholder="Description" >
  53.             </div>
  54.           </div>
  55.          
  56.           <div class="form-group row">
  57.             <label for="sku" class="col-sm-2 col-form-label">Sku</label>
  58.             <div class="col-sm-10">
  59.               <input name="sku" class="form-control" id="sku" placeholder="Sku">
  60.             </div>
  61.           </div>
  62.          
  63.           <div class="form-group row">
  64.             <label for="image" class="col-sm-2 col-form-label">Images</label>
  65.             <div class="col-sm-10">
  66.             <select class="form-control" id="img" name="img">
  67.               <?php
  68.              
  69.               $query = $database_connection_pdo->prepare("SELECT * from images");
  70.               $result = $query->execute();
  71.              
  72.               if($result){
  73.  
  74.                   while($row = $query->fetch()){
  75.  
  76.                       echo '<option>'. $row['filename'] .'</option>';
  77.                      
  78.                   }
  79.                  
  80.               }
  81.              
  82.              ?>
  83.             </select>
  84.             </div>
  85.           </div>
  86.          
  87.           <div class="form-group row">
  88.             <div class="col-sm-10">
  89.               <button type="submit" class="btn btn-primary">Add</button>
  90.             </div>
  91.           </div>
  92.         </form>
  93.     </div>
  94. </body>
  95.  
  96. <?php
  97.  
  98. include 'footer.php';
  99.  
  100. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top