Skip to content

Instantly share code, notes, and snippets.

@tony1223
Created October 13, 2012 15:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony1223/3885073 to your computer and use it in GitHub Desktop.
Save tony1223/3885073 to your computer and use it in GitHub Desktop.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Controller {
public function register()
{
$this->load->view('register');
}
public function login(){
$this->load->view('login');
}
public function registering(){
$account = $this->input->post("account");
$password= $this->input->post("password");
$passwordrt= $this->input->post("passwordrt");
if( trim($password) =="" || trim($account) =="" ){
$this->load->view('register',Array(
"errorMessage" => "Account or Password shouldn't be empty,please check!" ,
"account" => $account
));
return false;
}
if( $password != $passwordrt ){
//如果不一致,我們讀取 register view,
//但將 $account 跟錯誤訊息帶入作為處理
$this->load->view('register',Array(
"errorMessage" => "Password doesn't match re-type password,please check yout input!" ,
"account" => $account
));
return false;
}
$this->load->model("UserModel");
if($this->UserModel->checkUserExist(trim($account))){ //檢查帳號是否重複
$this->load->view('register',Array(
"errorMessage" => "This account is already in used." ,
"account" => $account
));
return false;
}
$this->UserModel->insert(trim($account),trim($password)); //完成新增動作
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment