Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Headers
- header('Access-Control-Allow-Origin: *');
- header('Content-Type: transaction_type/json');
- header('Access-Control-Allow-Methods: POST');
- header('Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Access-Control-Allow-Methods, Authorization,X-Requested-With');
- include_once '../../config/Database.php';
- include_once '../../models/Trades.php';
- // Instantiate DB & connect
- $database = new Database();
- $db = $database->connect();
- // Instantiate blog post object
- $trades = new Trades($db);
- // Get raw posted data
- $data = json_decode(file_get_contents("php://input"));
- $trades->plant_type = $data->plant_type;
- $trades->name = $data->name;
- $trades->town = $data->town;
- $trades->phone = $data->phone;
- $trades->transaction_type = $data->transaction_type;
- $trades->descryption = $data->descryption;
- // Create Plant
- if($trades->create()) {
- echo json_encode(
- array('message' => 'Plant Created')
- );
- } else {
- echo json_encode(
- array('message' => 'Plant Not Created')
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement