Beispiel #1
0
}
include 'includes/connection.php';
?>

<?php 
if (isset($_POST["submit"])) {
    $name = mysql_prep($_POST["name"]);
    $email = mysql_prep($_POST["email"]);
    $password = mysql_prep($_POST["password"]);
    $gender = $_POST["gender"];
    $contact = mysql_prep($_POST["contact"]);
    $date_of_birth = mysql_prep($_POST["date_of_birth"]);
    $address = mysql_prep($_POST["address"]);
    $role = $_POST["role"];
    $user_id = genarate_user_id($role);
    $id = get_id_by_email($_GET['email']);
    $query = "UPDATE user \n\t\tSET Name = '{$name}', User_Id = '{$user_id}', Email = '{$email}', Password = '******', \n\t\tGender = '{$gender}', ContactNo = '{$contact}', DateOfBirth = '{$date_of_birth}', \n\t\tAddress = '{$address}', Role = '{$role}' \n\t\tWHERE ID = '{$id}';";
    global $connection;
    $rs = mysql_query($query, $connection);
    confirm_query($rs);
    if (isset($rs)) {
        redirect_to("profile.php?email=" . urlencode($email));
    }
}
?>

<?php 
require_once 'includes/header.php';
?>

<?php 
Beispiel #2
0
 function login()
 {
     $this->data['title'] = "Login";
     //validate form input
     $this->form_validation->set_rules('identity', 'Identity', 'required');
     $this->form_validation->set_rules('password', 'Password', 'required');
     //check to see if the user is logging in
     $jsondata = file_get_contents(get_api_key() . 'users/lists/format/json');
     //convert json object to php associative array
     $data = json_decode($jsondata, true);
     //print_mz($data);
     if ($this->form_validation->run() == true) {
         $last_link = $this->session->userdata('last_link');
         $nik = $this->input->post('identity');
         $email = !empty($data['EMAIL']) ? $data['EMAIL'] : $this->input->post('identity');
         $user_id = !empty(get_id($nik)) ? get_id($nik) : get_id_by_email($email);
         $last_login = $this->db->select('last_login')->where('nik', $nik)->or_where('email', $email)->get('users')->row('last_login');
         $first_login = !empty($last_login) ? '' : '1';
         if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'))) {
             if (!empty($last_link)) {
                 redirect($last_link);
             } else {
                 if (!is_admin()) {
                     redirect('person/detail/' . $user_id . '/' . $first_login, 'refresh');
                 }
                 $this->session->set_flashdata('message', $this->ion_auth->messages());
                 redirect('/', 'refresh');
             }
         } elseif ($this->cekNik($data, 'EMPLID', $this->input->post('identity')) == TRUE && $this->input->post('password') == 'password' && is_registered($this->input->post('identity')) == false) {
             $getdata = file_get_contents(get_api_key() . 'users/list/EMPLID/' . $this->input->post('identity') . '/format/json');
             $data = json_decode($getdata, true);
             $username = $data['NAME'];
             $password = $this->input->post('password');
             $additional_data = array('first_name' => $data['FIRSTNAME'], 'last_name' => $data['LASTNAME'], 'nik' => $this->input->post('identity'), 'bod' => date('Y-m-d', strtotime($data['BIRTHDATE'])), 'phone' => $data['PHONE'], 'marital_id' => $data['MARITALSTATUS'], 'previous_email' => $data['SMS'], 'bb_pin' => $data['PINBLACKBERRY']);
             if ($this->ion_auth->register($username, $password, $email, $additional_data)) {
                 $this->send_email_inventory($data['EMPLID']);
                 $mch = array('mchID' => get_mchid($nik));
                 $this->db->where('nik', $nik);
                 $this->db->update('users', $mch);
                 /*if( $this->send_email_notification($data['EMPLID'])){
                       $this->session->set_flashdata('message', 'Account is inactive');
                       redirect("auth/login", 'refresh');
                   }else{
                       $this->session->set_flashdata('message', 'Activation Is Inactive');
                       
                   }*/
                 $this->send_email_activation($data['EMPLID']);
                 $this->session->set_flashdata('message', 'Account is inactive');
                 redirect("auth/login", 'refresh');
             } else {
                 $this->session->set_flashdata('message', 'Wrong Password or Account is still inactive, Please Contact The Administrator');
                 redirect("auth/login", 'refresh');
             }
         } else {
             $this->session->set_flashdata('message', $this->ion_auth->errors());
             redirect('auth/login', 'refresh');
         }
     } else {
         //the user is not logging in so display the login page
         //set the flash data error message if there is one
         $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
         $this->data['identity'] = array('name' => 'identity', 'id' => 'identity', 'type' => 'text', 'value' => $this->form_validation->set_value('identity'), 'placeholder' => 'NIK / E-mail', 'required' => 'required');
         $this->data['password'] = array('name' => 'password', 'id' => 'password', 'type' => 'password', 'placeholder' => 'Password', 'required' => 'required');
         $this->_render_page('auth/login', $this->data);
     }
 }