PHP Classes

File: api/userreg-api.php

Recommend this page to a friend!
  Packages of Adeleye Ayodeji   Simple REST API   api/userreg-api.php   Download  
File: api/userreg-api.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple REST API
Example of REST API using the MVC design pattern
Author: By
Last change:
Date: 2 years ago
Size: 628 bytes
 

 

Contents

Class file image Download
<?php
    include "../include/autoload.php";

    header("Content-Type: application/json");

    if (isset($_POST["username"])) {
        //Getting details from the form
        $username = $_POST["username"];
        $firstname = $_POST["first"];
        $lastname = $_POST["last"];

        //Creating an instance of a Class
        $new_user = new UserController();
        $response[] = $new_user->addNewUser($username, $firstname, $lastname);
        echo json_encode($response);
    }else{
        $error[] = array("message" => "POST username is not set");
        echo json_encode($error);
    }


?>