Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
4 changes: 2 additions & 2 deletions application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array();
$autoload['libraries'] = array('session', 'database', 'form_validation','upload');

/*
| -------------------------------------------------------------------
Expand Down Expand Up @@ -89,7 +89,7 @@
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array();
$autoload['helper'] = array('url', 'form','file');

/*
| -------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = '';
$config['base_url'] = 'https://localhost/vietgramci/vietgramcifix';

/*
|--------------------------------------------------------------------------
Expand All @@ -35,7 +35,7 @@
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
$config['index_page'] = '';

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'username' => 'root',
'password' => '',
'database' => '',
'database' => 'db_vigfix',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
Expand Down
2 changes: 1 addition & 1 deletion application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
| 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;
30 changes: 30 additions & 0 deletions application/controllers/Edit_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Edit_profile extends CI_Controller {

function __construct(){
parent::__construct();
$this->load->model('model_IG');
$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),
"phone" => $this->input->post('phone', true),
"gender" => $this->input->post('gender', true),
];
$this->model_IG->edit_profile($_SESSION['username'], $data);
redirect('/profile','refresh');
}
}
?>
28 changes: 28 additions & 0 deletions application/controllers/Feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class feed extends CI_Controller {

function __construct(){
parent::__construct();
$this->load->model('model_IG');
$this->load->library('session');
}

public function index()
{
if($this->session->userdata('username')){
$data = $this->model_IG->get_profile($this->session->userdata('username'));
$this->load->view('feed',$data);
}
else{
redirect('/login');
}
}

public function logout(){
$this->session->sess_destroy();
redirect('/login');
}
}
?>
30 changes: 30 additions & 0 deletions application/controllers/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller {

function __construct(){
parent::__construct();
$this->load->model('model_IG');
$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->model_IG->login($data)) {
$this->session->set_userdata('username', $this->input->post('username'));
redirect('/feed');
}
else {
redirect('/login');
}
}
}
?>
18 changes: 18 additions & 0 deletions application/controllers/Profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Profile extends CI_Controller {

function __construct(){
parent::__construct();
$this->load->model('model_IG');
$this->load->library('session');
}

public function index()
{
$data = $this->model_IG->get_profile($this->session->userdata('username'));
$this->load->view('Profile', $data);
}
}
?>
40 changes: 40 additions & 0 deletions application/models/model_IG.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
class model_IG extends CI_Model{

public function login($data) {
$query = $this->db->where('username', $data['username'])->where('password', $data['password'])->get('user');
if($query->num_rows() > 0){
return true;
}else{
return false;
}
}
public function get_profile($username){
if($this->db->where('username', $username)){
return $this->db->get('user')->row_array();
}else{
return false;
}
}
public function get_datafoto(){
$this->db->select('*');
$this->db->from('user');
$this->db->join('photo','user.username=user.username','LEFT OUTER');
$query = $this->db->get();
return $query->result();
}
public function edit_profile($username,$data)
{
$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),
"phone"=> $this->input->post('phone',true),
"gender" => $this->input->post('gender', true),
];
$this->db->where('username', $username);
return $this->db->update('profile', $data);
}
}
?>
132 changes: 132 additions & 0 deletions application/views/edit_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="en">
<?php

$data_photo = $this->db->query("select * from photo where username='". $_SESSION['username']. "'");
$jmlData = $data_photo->num_rows();
$data = $this->db->get('profile')->row_array();
foreach($data_photo->result() as $row[]){
}
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Edit Profile | Vietgram</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/styles.css">
</head>

<body>
<nav class="navigation">
<div class="navigation__column">
<a href="<?php base_url()?>feed">
<img src="assets/images/logo.png" />
</a>
</div>
<div class="navigation__column">
<i class="fa fa-search"></i>
<input type="text" placeholder="Search">
</div>
<div class="navigation__column">
<ul class="navigations__links">
<li class="navigation__list-item">
<a href="<?php base_url()?>feed/logout" class="navigation__link">
<i class="fa fa-sign-out"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="#" class="navigation__link">
<i class="fa fa-compass fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="#" class="navigation__link">
<i class="fa fa-heart-o fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="<?php base_url()?>Profile" class="navigation__link">
<i class="fa fa-user-o fa-lg"></i>
</a>
</li>
</ul>
</div>
</nav>
<main id="edit-profile">
<div class="edit-profile__container">
<header class="edit-profile__header">
<div class="edit-profile__avatar-container">
<img src="assets/images/GAMBARAVA.jpg" class="edit-profile__avatar" />
</div>
<h4 class="edit-profile__username"><?php echo $_SESSION['username'];?></h4>
</header>
<form action="<?php base_url()?>edit_Profile/editprofile" class="edit-profile__form" method="post">
<div class="form__row">
<label for="full-name" class="form__label">Name:</label>
<input name="name" type="text" class="form__input" value="<?php echo $data['name']?>"/>
</div>
<div class="form__row">
<label for="user-name" class="form__label">Username:</label>
<input name="user-name" type="text" class="form__input" value="<?php echo $_SESSION['username']?>" disabled/>
</div>
<div class="form__row">
<label for="website" class="form__label">Website:</label>
<input name="website" type="url" class="form__input" value="<?php echo $data['website']?>"/>
</div>
<div class="form__row">
<label for="bio" class="form__label">Bio:</label>
<textarea name="bio"><?php echo $data['bio']?></textarea>
</div>
<div class="form__row">
<label for="email" class="form__label">Email:</label>
<input name="email" type="email" class="form__input" value="<?php echo $data['email']?>"/>
</div>
<div class="form__row">
<label for="phone" class="form__label">Phone Number:</label>
<input name="phone" type="tel" class="form__input" value="<?php echo $data['phone']?>"/>
</div>
<div class="form__row">
<label for="gender" class="form__label">Gender:</label>
<select name="gender">
<?php
if($data['gender'] == 0) {
?>
<option value="0" selected>Female</option>
<option value="1">Male</option>
<?php } else { ?>
<option value="0">Female</option>
<option value="1" selected>Male</option>
<?php } ?>


</select>
</div>
<input type="submit" value="Submit">
</form>
</div>
</main>
<footer class="footer">
<div class="footer__column">
<nav class="footer__nav">
<ul class="footer__list">
<li class="footer__list-item"><a href="#" class="footer__link">About Us</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Support</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Blog</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Press</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Api</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Jobs</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Privacy</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Terms</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Directory</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Language</a></li>
</ul>
</nav>
</div>
<div class="footer__column">
<span class="footer__copyright">© 2017 Vietgram</span>
</div>
</footer>
</body>

</html>
Loading