private function getContacts()
 {
     $this->table = 'contacts';
     //Select query
     $this->query_string = "SELECT * FROM %s WHERE user_id = '%s'";
     //Package array for query arguments
     $this->packageArguments();
     //Connect to database
     $this->db = DbConnect::get();
     //Query db
     $this->result = $this->db->query($this->query_string, $this->arguments);
     //Reset Session
     $this->contacts_array = array();
     //Turn result into associative array
     if (mysql_num_rows($this->result)) {
         while ($this->contacts = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
             $this->contact = array('contact_id' => $this->contacts['id'], 'first_name' => $this->contacts['first_name'], 'last_name' => $this->contacts['last_name'], 'phone_one' => $this->contacts['phone_one'], 'phone_two' => $this->contacts['phone_two'], 'phone_three' => $this->contacts['phone_three'], 'email' => $this->contacts['email'], 'company' => $this->contacts['company'], 'address_one' => $this->contacts['address_one'], 'address_two' => $this->contacts['address_two'], 'city' => $this->contacts['city'], 'state' => $this->contacts['state'], 'zip_code' => $this->contacts['zip_code'], 'notes' => $this->contacts['notes']);
             array_push($this->contacts_array, $this->contact);
         }
         return $this->contacts_array;
     } else {
         $this->error_message = "You have No Contacts";
         return $this->error_message;
     }
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $this->user_name = $_SESSION['current_user'];
     //Connect to database
     $this->db = DbConnect::get();
     //$this->endConvo();
     //$this->deleteMessages();
     $this->logout();
     $this->endSession();
 }
 private function handleInfo()
 {
     //If no errors, query db
     if (!isset($this->error_message)) {
         //Update query
         $this->query_string = "UPDATE %s SET first_name = '%s', last_name = '%s', phone_one = '%s', phone_two = '%s', phone_three = '%s', email = '%s', company = '%s', address_one = '%s', address_two = '%s', city = '%s', state = '%s', zip_code = '%s', notes = '%s', user_id = '%s' WHERE id = '%s';";
         //Package array for query arguments
         $this->packageEditArguments();
         //Connect to database
         $this->db = DbConnect::get();
         //call query method
         $this->result = $this->db->query($this->query_string, $this->arguments);
         $this->return_array = array('id' => $this->real_contact_id, 'errorMessage' => NULL);
         //If errors, set session and redirect
     } else {
         $this->return_array = array('id' => $this->real_contact_id, 'errorMessage' => $this->error_message);
     }
 }
Exemplo n.º 4
0
 private function handleInfo()
 {
     //If no errors, query db
     if (!isset($this->errorMsg)) {
         $this->first_name = $this->postArray['First Name'];
         $this->user_name = $this->postArray['User Name'];
         $this->password = $this->postArray['Password'];
         $this->table = "users";
         $this->logged_in = "0";
         //Encrypt login
         $this->encryptLogin();
         //Select query
         $this->query_string = "SELECT * FROM %s WHERE user_name = '%s'";
         //Package array for query arguments
         $this->packageArguments();
         //Connect to database
         $this->db = DbConnect::get();
         //call query method
         $this->result = $this->db->query($this->query_string, $this->arguments);
         //Turn result into associative array
         $this->line = mysql_fetch_array($this->result, MYSQL_ASSOC);
         //Check to see if user name already exists and redirect, else create new user
         if ($this->line) {
             $this->errorMsg .= 'User Name Already Exists';
             $_SESSION['error'] = $this->errorMsg;
             header("Location: ../index.php");
         } else {
             //Select query
             $this->query_string = "INSERT INTO %s (first_name, user_name, password, logged_in) VALUES('%s', '%s', '%s', '%s');";
             //Package array for query arguments
             $this->packageInsertArguments();
             //call query method
             $this->result = $this->db->query($this->query_string, $this->arguments);
             $this->errorMsg .= 'Account Created, Please Log in';
             $_SESSION['error'] = $this->errorMsg;
             header("Location: ../index.php");
         }
         //If errors, set session and redirect
     } else {
         $_SESSION['error'] = $this->errorMsg;
         header("Location: ../index.php");
     }
 }
Exemplo n.º 5
0
 public function __construct()
 {
     $this->user_name = $_POST['userName'];
     $this->password = $_POST['password'];
     $this->table = "users";
     //Connect to database
     $this->db = DbConnect::get();
     //Call validate method
     $this->validate();
     //Encrypt login
     $this->encryptLogin();
     //Select query
     $this->query_string = "SELECT * FROM %s WHERE user_name = '%s' AND password = '******'";
     //$this->selectQuery("SELECT * FROM %s WHERE user_name = '%s' AND password = '******'");
     //Package array for query arguments
     $this->packageArguments();
     //call query method
     $this->result = $this->db->query($this->query_string, $this->arguments);
     //
     $this->handleResults();
 }
Exemplo n.º 6
0
 private function handleInfo()
 {
     //If no errors, query db
     if (!isset($this->error_message)) {
         $this->first_name = $_POST['firstName'];
         $this->last_name = $_POST['lastName'];
         $this->phone_one = $_POST['phone1'];
         $this->phone_two = $_POST['phone2'];
         $this->phone_three = $_POST['phone3'];
         $this->email = $_POST['email'];
         $this->company = $_POST['company'];
         $this->address_one = $_POST['address1'];
         $this->address_two = $_POST['address2'];
         $this->city = $_POST['city'];
         $this->state = $_POST['state'];
         $this->zip_code = $_POST['zipCode'];
         $this->notes = $_POST['notes'];
         $this->table = "contacts";
         //Insert query
         $this->query_string = "INSERT INTO %s (first_name, last_name, phone_one, phone_two, phone_three, email, company, address_one, address_two, city, state, zip_code, notes, user_id) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');";
         //Package array for query arguments
         $this->packageInsertArguments();
         //Connect to database
         $this->db = DbConnect::get();
         //call query method
         $this->result = $this->db->query($this->query_string, $this->arguments);
         //Grab last id from inserted row
         //$this->contact_id = mysql_insert_id();
         //Check to see if user name already exists and redirect, else create new user
         if ($this->result) {
             //Select query
             $this->query_string = "SELECT * FROM %s WHERE user_id = %s ORDER BY id DESC LIMIT 1;";
             //Package array for query arguments
             $this->packageSelectArguments();
             //Connect to database
             $this->db = DbConnect::get();
             //call query method
             $this->result = $this->db->query($this->query_string, $this->arguments);
             $this->line = mysql_fetch_array($this->result, MYSQL_ASSOC);
             $this->contact_id = $this->line['id'];
             $this->return_array = array('id' => $this->contact_id, 'data' => $this->line, 'errorMessage' => NULL);
         } else {
             $this->error_message = 'Unable to add contact';
             $this->return_array = array('id' => $this->contact_id, 'errorMessage' => $this->error_message);
         }
         //If errors, set session and redirect
     } else {
         $this->return_array = array('id' => $this->contact_id, 'errorMessage' => $this->error_message);
     }
 }