Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $response = array();
- if (isset($_POST['name']) & isset($_POST['price']) & isset($_POST['description'])) {
- require_once __DIR__ . '/db_connect.php';
- $db = new DB_CONNECT();
- $name = _POST['name'];
- $price = _POST['price'];
- $description = _POST['description'];
- $result = msql_query("INSERT INTO products(name, price, description) VALUES('$name', '$price', '$description')");
- if ($result) {
- $response["success"] = 1;
- $response["message"] = "Product successfully create";
- } else {
- $response["success"] = 0;
- $response["message"] = "Oops! An error occurred.";
- }
- } else {
- $response["success"] = 0;
- $response["message"] = "Required field(s) is missing";
- }
- echo json_encode($response);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement