Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

js data php

// In your controller
if(isset($_POST)){

    $obj = new MyObject();
    $obj->name = $_POST['name'];
    $obj->date = date("Y-m-d");
    $obj->validatePost();
    $obj->update();

    $result = $obj->getData();
    return $result;

}


// Your model
class MyObject {

    public $name;
    public $date;

    public function validatePost(){
        if($this->name == null){
            // print error
        }
    }

    public function update(){
        // database cheets
    }

    public function getData(){
        return $json;
    }

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #data #php
ADD COMMENT
Topic
Name
1+3 =