Created
October 14, 2012 13:39
-
-
Save tony1223/3888625 to your computer and use it in GitHub Desktop.
CI Guide
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
<!DOCTYPE html> | |
<html > | |
<head> | |
<meta charset="utf-8"> | |
<title><?php | |
if(isset($pageTitle)){ | |
echo $pageTitle ; //透過變數設定 | |
} else{ | |
echo "發文系統" ; //預設標題 | |
} | |
?></title> | |
<link rel="stylesheet" href="<?=base_url("/css/bootstrap.min.css")?>"> | |
<link rel="stylesheet" href="<?=base_url("/css/bootstrap-responsive.min.css")?>"> | |
</head> | |
<body> |
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 include("_site_header.php"); ?> | |
<div class="container"> | |
<div class="alert alert-success"> | |
恭喜你 (<?=$account?>),你已經完成註冊, | |
接下來馬上到登入頁面去試試看吧! | |
<a href="<?=site_url("user/login")?>">登入</a> | |
</div> | |
</div> | |
<?php include("_site_footer.php"); ?> |
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($account)){ | |
$this->load->view('register',Array( | |
"errorMessage" => "This account is already in used." , | |
"account" => $account | |
)); | |
return false; | |
} | |
$this->UserModel->insert(trim($account),trim($password)); //完成新增動作 | |
$this->load->view('register_success',Array( | |
"account" => $account, | |
"pageTitle" => "發文系統 - 會員註冊成功" | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment