Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. require_once 'includes/connection.php';
  2.  
  3. class addProduct{
  4. public function insert() {
  5.  
  6. global $conn;
  7.  
  8. // Cheking if fields are not empty
  9. if (isset($_POST['submit'])) {
  10. if (($_POST['SKU'] == "") || ($_POST['Name'] == "") || ($_POST['Price'] == ""))
  11. {
  12. echo "Fill all fields";
  13. // Do query to INSERT information in to the DB, if all fields are filled with text
  14. } else {
  15. $SKU = $_POST['SKU'];
  16. $Name = $_POST['Name'];
  17. $Price = $_POST['Price'];
  18. $Type = $_POST['Type'];
  19. $sqlinsert = "INSERT INTO products (SKU, Name, Price, Type) VALUES ('$SKU', '$Name', '$Price', '$Type')";
  20. $conn->query($sqlinsert);
  21. echo "Product successfully added";
  22. }
  23.  
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement