XD 11點了~~!
直奔程式碼
controllesrs/users.php
<?php
class users extends CI_Controller{
function __construct() {
parent::__construct();
//載入資料庫行為
$this->load->model('users_sql');
/**請參考 http://www.codeigniter.org.tw/user_guide/helpers/url_helper.html **/
$this->load->helper('url');
}
function index(){
$this->load->view('login');
}
function login(){
$where = $this->input->post();
$query = $this->users_sql->where_array($where,'users');
/*num_rows() 請參考 : http://www.codeigniter.org.tw/user_guide/database/results.html*/
if($query->num_rows() > 0){
$data['name'] = $this->input->post('account');
$data['content'] = 'HI!HI!';
$this->user($data);
}else{
redirect(site_url().'users/index');
}
}
function user($array){
$this->load->view('user',$array);
}
}
?>
補充
views/login.php
//表單補傳送網址
<form id="form1" name="form1" method="post" action="<?=$link;?>index1.php/users/login">
完成圖
明天來補強程式
待續...