Ejemplo n.º 1
0
 /**
  * Handling a post.
  */
 function post()
 {
     // Call to neccessary variables and helpers
     $new_id = $_POST['id'];
     $this->load->helper('validate_helper');
     // Check to see if the ID already exists
     if ($this->products->get($new_id) != null) {
         $this->data['errors'][] = 'ID already in use.';
     }
     // Check to see if the ID is invalid
     if (!validate_id($_POST['id'])) {
         $this->data['errors'][] = 'Invalid ID.';
     }
     // Check to see if the status is invalid.
     if (!validate_status($_POST['status'])) {
         $this->data['errors'][] = 'Invalid status.';
     }
     // If more than 0 errors exist, adding entry fails, error produced
     if (count($this->data['errors']) > 0) {
         redirect('../add');
         //$this -> index();
     } else {
         $this->products->add($_POST);
         redirect('../');
     }
 }
Ejemplo n.º 2
0
 /**
  * Handling a post.
  */
 function post()
 {
     $new_id = $_POST['id'];
     $this->load->helper('validate_helper');
     // Check to see if the ID already exists
     if ($this->accounts->get($new_id) == null) {
         $this->data['errors'][] = 'ID does not exist.';
     }
     // Check to see if the ID is invalid
     if (!validate_id($_POST['id'])) {
         $this->data['errors'][] = 'Invalid ID.';
     }
     // Check to see if the status is invalid.
     if (!validate_status($_POST['status'])) {
         $this->data['errors'][] = 'Invalid status.';
     }
     // If more than 0 errors exist, adding entry fails, error produced
     if (count($this->data['errors']) > 0) {
         redirect('../update');
         //$this -> index();
     } else {
         $this->accounts->update($_POST);
         redirect('../');
     }
 }