Created
October 13, 2012 15:47
-
-
Save tony1223/3885073 to your computer and use it in GitHub Desktop.
This file contains 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 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