aakash2310

Untitled

Oct 11th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <link rel="stylesheet" href="style.css">
  6. </head>
  7. <body>
  8. <form method = "post">
  9.         <div class="container">
  10.             ProdID
  11.             <input type="text" name="pid">
  12.             PName
  13.             <input type="text" name="pname">
  14.             descc
  15.             <input type="text" name="descc">
  16.             Price
  17.             <input type="text" name="price">
  18.             Qty
  19.             <input type="text" name="qty">
  20.             Category
  21.             <input type="text" name="category">
  22.             PImg
  23.             <input type="text" name="pimg">
  24.             <input type="submit" name="insert" value="Insert" class="registerbtn">
  25.         </div>
  26. </form>
  27. </body>
  28. </html>
  29.  
  30. <?php
  31.     require "db.php";
  32.     if(isset($_POST['insert']))
  33.     {
  34.         $pid = $_POST["pid"];
  35.         $pname = $_POST["pname"];
  36.         $pdesc = $_POST["descc"];
  37.         $pprice = $_POST["price"];
  38.         $pqty = $_POST["qty"];
  39.         $pcat = $_POST["category"];
  40.         $pimg = $_POST["pimg"];
  41.         $stmt = $conn->prepare("INSERT INTO ProductDB(ProdID,PName,descc,Price,Qty,Category,PImg) VALUES (?,?,?,?,?,?,?)");
  42.         $stmt-> bind_param("sssiiss",$pid,$pname,$pdesc,$pprice,$pqty,$pcat,$pimg);
  43.         if($stmt->execute())
  44.         {
  45.             echo '<script language="javascript">';
  46.             echo 'alert("Inserted Successfull")';
  47.             echo '</script>';
  48.         }
  49.         else{
  50.             echo "Failed To Connect". $conn ->error;
  51.         }
  52.     }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment