Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once 'includes/connection.php';
- class addProduct{
- public function insert() {
- global $conn;
- // Cheking if fields are not empty
- if (isset($_POST['submit'])) {
- if (($_POST['SKU'] == "") || ($_POST['Name'] == "") || ($_POST['Price'] == ""))
- {
- echo "Fill all fields";
- // Do query to INSERT information in to the DB, if all fields are filled with text
- } else {
- $SKU = $_POST['SKU'];
- $Name = $_POST['Name'];
- $Price = $_POST['Price'];
- $Type = $_POST['Type'];
- $sqlinsert = "INSERT INTO products (SKU, Name, Price, Type) VALUES ('$SKU', '$Name', '$Price', '$Type')";
- $conn->query($sqlinsert);
- echo "Product successfully added";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement