Skip to content
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('database','session','form_validation');

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

/*
| -------------------------------------------------------------------
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'] = 'http://localhost/igcodeigniter/';

/*
|--------------------------------------------------------------------------
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_webpro',
'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'] = 'Auth';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
48 changes: 48 additions & 0 deletions application/controllers/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Login extends CI_Controller {

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

public function index() {
$this->form_validation->set_rules('username', 'Username', 'required|trim');
$this->form_validation->set_rules('password', 'Password', 'required|trim');

if ($this->form_validation->run() == FALSE) {
$this->load->view('view_login');
} else {
$this->do_login();
}
}

private function do_login() {
$username = $this->input->post('username');
$password = $this->input->post('password');

$user = $this->ig_model->login($username, $password);
if ($user) {
$profile = $this->ig_model->getProfile($user['username']);

$this->session->set_userdata($profile);
redirect('ig_controller');
} else {
redirect('Login');
}
}

public function do_logout() {
$this->session->unset_userdata('username');
redirect('Login');
}

}
/* End of file Login.php */
/* Location: ./application/controllers/Login.php */

?>
36 changes: 36 additions & 0 deletions application/controllers/ig_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Ig_controller extends CI_Controller {

public function __construct()
{
parent::__construct();

if (!$this->session->userdata('username')) {
redirect('Login');
}

$this->load->model('ig_model');
}

public function index() {
$this->load->view('profile');
}
public function edit_Profile() {
$this->load->view('edit-profile');
}

public function feed() {
$this->load->view('feed');
}

public function explore() {
$this->load->view('explore');
}

}
/* End of file ig_controller.php */
/* Location: ./application/controllers/ig_controller.php */

?>
25 changes: 25 additions & 0 deletions application/controllers/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('view_login');
}
}
27 changes: 27 additions & 0 deletions application/models/ig_model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Ig_model extends CI_Model {

public function getProfile($username) {
return $this->db->get_where('profile', [
'username' => $username
])->row_array();
}
public function login($username, $password) {
return $this->db->get_where('user', [
'username' => $username,
'password' => $password
])->row_array();
}

public function editProfile($data, $username) {
$this->db->where('username', $username);
$this->db->update('profile', $data);
}

}

/* End of file ig_model.php */
/* Location: ./application/models/ig_model.php */
?>
42 changes: 42 additions & 0 deletions application/views/box-model.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<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>Box Model</title>
<style>
.father{
background-color: red;
height:3000px;
width:600px;
position: relative;
}
.child{
width:50%;
height:300px;
background-color:blue;

}
.d-child{
width:50%;
height:300px;
background-color:yellow;
position: absolute;
right:0px;
top:-10px;
}
</style>
</head>
<body>
<div class="father">
<div class="another">
<div class="something">
<div class="child">
</div>
<div class="d-child"></div>
</div>
</div>
</div>
</body>
</html>
112 changes: 112 additions & 0 deletions application/views/edit-profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="en">
<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="<?= base_url('assets/css/styles.css'); ?>">
</head>

<body>
<nav class="navigation">
<div class="navigation__column">
<a href="feed.html">
<img src="<?= base_url('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="<?= site_url('ig_controller/explore') ?>" 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="<?= site_url('ig_controller') ?>" 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="<?= base_url('assets/images/avatar.jpg'); ?>" class="edit-profile__avatar" />
</div>
<h4 class="edit-profile__username"><?= $this->session->userdata('username') ?></h4>
</header>

<form action="<?= site_url('ig_controller/index') ?>" class="edit-profile__form" method="post">
<div class="form__row">
<label for="full-name" class="form__label">Name:</label>
<input id="full-name" type="text" class="form__input" value="<?= $this->session->userdata('name') ?>"/>
</div>
<div class="form__row">
<label for="user-name" class="form__label">Username:</label>
<input id="user-name" type="text" class="form__input" value="<?= $this->session->userdata('username') ?>" />
</div>
<div class="form__row">
<label for="website" class="form__label">Website:</label>
<input id="website" type="url" class="form__input" value="<?= $this->session->userdata('website')?>"/>
</div>
<div class="form__row">
<label for="bio" class="form__label">Bio:</label>
<textarea id="bio"><?= $this->session->userdata('bio') ?></textarea>
</div>
<div class="form__row">
<label for="email" class="form__label">Email:</label>
<input id="email" type="email" class="form__input" value="<?= $this->session->userdata('email') ?>" />
</div>
<div class="form__row">
<label for="phone" class="form__label">Phone Number:</label>
<input id="phone" type="tel" class="form__input" value="<?= $this->session->userdata('phonenumber') ?>"/>
</div>
<div class="form__row">
<label for="gender" class="form__label">Gender:</label>
<select id="gender">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="cant">Can't remember</option>
</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