Last active
February 11, 2016 10:30
-
-
Save peerapongsam/8876935ed351a8cef423 to your computer and use it in GitHub Desktop.
CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Login extends CI_Controller | |
{ | |
public function index() | |
{ | |
$this->load->helper('form'); | |
$this->load->view('login'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class VerifyLogin extends CI_Controller | |
{ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->load->model('user', '', true); | |
} | |
public function index() | |
{ | |
$this->load->helper('security'); | |
$this->load->library('form_validation'); | |
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean'); | |
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database'); | |
if ($this->form_validation->run() == false) { | |
echo 'Login False'; | |
} else { | |
echo 'Login Success'; | |
} | |
} | |
public function check_database($password) | |
{ | |
$username = $this->input->post('username'); | |
$result = $this->user->login($username, $password); | |
if ($result) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User extends CI_Model | |
{ | |
public function login($username, $password) | |
{ | |
return true; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Login</title> | |
</head> | |
<body> | |
<?=validation_errors(); ?> | |
<?=form_open('verifylogin')?> | |
<label for="username">Username:</label> | |
<input type="text" name="username" id="username" size="20"> | |
<br/> | |
<label for="password">Password:</label> | |
<input type="password" name="password" id="password" size="20"> | |
<br> | |
<input type="submit" name="login" value="Login"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment