File: /home/awaldron/www/archive/teampay/application/controllers/my_account.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class My_account extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('security');
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
}
function index()
{
// Initialize page variables
$data = $this->tank_auth->auth_init( true, '');
$data['page_title'] = "Change Account Info";
$data['icon_title'] = "fa-info-circle";
$data['navon'] = "my_account";
$data['msg'] = '';
$post = $this->input->post();
if (isset($post['email'])) {
$this->form_validation->set_rules('fname', 'First Name', 'trim|required|xss_clean');
$this->form_validation->set_rules('lname', 'Last Name', 'trim|required|xss_clean');
$this->form_validation->set_rules('add1', 'Address 1', 'trim|required|xss_clean');
$this->form_validation->set_rules('add2', 'Address 2', 'trim|xss_clean');
$this->form_validation->set_rules('city', 'City', 'trim|required|xss_clean');
$this->form_validation->set_rules('state', 'State', 'trim|required|xss_clean');
$this->form_validation->set_rules('zip', 'Zip Code', 'trim|required|xss_clean');
$this->form_validation->set_rules('email', 'Email', 'trim|valid_email|required|xss_clean');
$this->form_validation->set_rules('phone', 'Phone', 'trim|required|xss_clean');
$this->form_validation->set_rules('user_paypal', 'PayPal Email', 'trim|valid_email|required|xss_clean');
// process account info change
if ($this->form_validation->run()) { // validation ok
// Format data
$post['phone'] = preg_replace("/[^0-9]/","", $post['phone']);
// send to model
$this->teampay_model->update_user($post, $data['user_id']);
$data['msg'] = "Sweet! Your account info has been updated.";
} else {
$data['navon'] = 'my_account';
$data['page_title'] = 'Account Update Error';
$data['icon_title'] = 'fa-gear';
$data['message'] = array('There was a problem processing this account update.', 'error');
$this->load->view('_header.php', $data);
$this->load->view('auth/general_message', $data);
$this->load->view('_footer.php', $data);
}
}
$data['user'] = $this->teampay_model->get_user( $data['user_id'] );
$this->load->view('_header', $data);
$this->load->view('v_myaccount', $data);
$this->load->view('_footer', $data);
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */