diff --git a/application/config/autoload.php b/application/config/autoload.php index 7cdc9013c11..5d691f08c68 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -58,7 +58,7 @@ | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('database','session','upload','form_validation'); /* | ------------------------------------------------------------------- @@ -89,7 +89,7 @@ | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array(); +$autoload['helper'] = array('url','file'); /* | ------------------------------------------------------------------- diff --git a/application/config/config.php b/application/config/config.php index 10315220e04..7b32315aebe 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = ''; +$config['base_url'] = 'https://localhost/CodeIgniter'; /* |-------------------------------------------------------------------------- @@ -35,7 +35,7 @@ | variable so that it is blank. | */ -$config['index_page'] = 'index.php'; +$config['index_page'] = ''; /* |-------------------------------------------------------------------------- diff --git a/application/config/routes.php b/application/config/routes.php index 1b45740d7c7..47ad1869650 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -43,12 +43,12 @@ | This is not exactly a route, but allows you to automatically route | controller and method names that contain dashes. '-' isn't a valid | class or method name character, so it requires translation. -| When you set this option to TRUE, it will replace ALL dashes in the -| controller and method URI segments. +| When you set this option to TRUE, it will replace ALL dashes with +| underscores in the controller and method URI segments. | | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'welcome'; +$route['default_controller'] = 'Login'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/controllers/Feed.php b/application/controllers/Feed.php new file mode 100644 index 00000000000..f8e20abeef7 --- /dev/null +++ b/application/controllers/Feed.php @@ -0,0 +1,28 @@ +load->model('userM'); + $this->load->library('session'); + } + + public function index() + { + if($this->session->userdata('username')){ + // $dataUser = $this->userM->get_datafoto(); + $data = $this->userM->get_profile($this->session->userdata('username')); + $this->load->view('feed',$data); + }else{ + redirect('/login'); + } + } + + public function logout(){ + $this->session->sess_destroy(); + redirect('/login'); + } +} +?> \ No newline at end of file diff --git a/application/controllers/Login.php b/application/controllers/Login.php new file mode 100644 index 00000000000..d926462d048 --- /dev/null +++ b/application/controllers/Login.php @@ -0,0 +1,28 @@ +load->model('userM'); + $this->load->library('session'); + } + + public function index() + { + $this->load->view('login'); + } + + public function aksi_login(){ + $data['username'] = $this->input->post('username'); + $data['password'] = $this->input->post('password'); + if($this->userM->login($data)) { + $this->session->set_userdata('username', $this->input->post('username')); + redirect('/feed'); + } else { + redirect('/login'); + } + } +} +?> \ No newline at end of file diff --git a/application/controllers/edit_profile.php b/application/controllers/edit_profile.php new file mode 100644 index 00000000000..ec30499fb27 --- /dev/null +++ b/application/controllers/edit_profile.php @@ -0,0 +1,30 @@ +load->model('userM'); + $this->load->library('session'); + } + + public function index() + { + $this->load->view('edit_profile'); + } + public function editprofile() + { + $data = [ + "name" => $this->input->post('name', true), + "website" => $this->input->post('website', true), + "bio" => $this->input->post('bio', true), + "email" => $this->input->post('email', true), + "nohp" => $this->input->post('nohp', true), + "gender" => $this->input->post('gender', true), + ]; + $this->userM->edit_profile($_SESSION['username'], $data); + redirect('/profile','refresh'); + } +} +?> \ No newline at end of file diff --git a/application/controllers/profile.php b/application/controllers/profile.php new file mode 100644 index 00000000000..48a091157fb --- /dev/null +++ b/application/controllers/profile.php @@ -0,0 +1,18 @@ +load->model('userM'); + $this->load->library('session'); + } + + public function index() + { + $data = $this->userM->get_profile($this->session->userdata('username')); + $this->load->view('Profile', $data); + } +} +?> \ No newline at end of file diff --git a/application/models/userM.php b/application/models/userM.php new file mode 100644 index 00000000000..edce7c8ce7a --- /dev/null +++ b/application/models/userM.php @@ -0,0 +1,21 @@ +db->query("SELECT * FROM `user` WHERE `username`='".$data['username']."' AND `password`='".md5($data['password'])."'"); + return $q->num_rows(); + } + public function getUser($id) + { + $q = $this->db->query("SELECT * FROM `profile` WHERE `id_profile`='$id'"); + return $q; + } + public function updateUser($id, $data) + { + $this->db->where('id_profile', $id); + $this->db->update('profile', $data); + + } +} \ No newline at end of file diff --git a/application/views/add_photo.php b/application/views/add_photo.php new file mode 100644 index 00000000000..6534229f905 --- /dev/null +++ b/application/views/add_photo.php @@ -0,0 +1,111 @@ + + + +
+ + + +