更新時間:笨:顯示動態誤差
RJZ:
TdjxQetc
是來自於數據庫,所以當我運行/確認/我應該得到對不起,你沒擁有的$activateCode
正確的激活碼,因爲我沒有通過任何變種($activateCode
),但是當我運行/確認/ $activateCode
我應該得到感謝您的帳戶現在活動,您可以登錄!並與else語句
我想它應該被改變,一個新的模型功能的開發,以檢查是否userActive
已被設置爲1
,然後顯示另一個$message
,這樣的鏈接才能使用。
查看:
<div class = "messages">
<?php if($confirmMessage != ''): ?>
<?php if($confirmError): ?>
<p class="error">
<?php echo $confirmMessage; ?>
</p>
<?php else: ?>
<p class="message">
<?php $confirmMessage?>
</p>
<?php endif; ?>
<?php endif; ?>
</div>
控制器:
function confirm(){
$activateCode = $this->uri->segment(3);
$error = FALSE;
$message = '';
if($activateCode == '')
{
$error = TRUE;
$message = 'Sorry you did not have a correct Activation Code.';
}
$userConfirmed = $this->users_model->confirm_user($activateCode);
if($userConfirmed){
$message = 'Thanks your account is now active you may login!';
}else{
$error = TRUE;
$message = 'I am sorry we do not have any details with that Activation Code';
}
$data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
$data['pageTitle'] = "User Confirm";
$data['confirmError'] = $error;
$data['confirmMessage'] = $message;
$this->load->view('frontend/assets/header', $data);
$this->load->view('frontend/user_confirm', $data);
$this->load->view('frontend/assets/footer');
}
我不確定爲什麼我沒有收到確認郵件,我只是得到我的觀點。該數據庫更新爲1
查看:
<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>
<p>Error: <?php echo validation_errors();?></p>
控制器:
function confirm(){
$activateCode = $this->uri->segment(3);
if($activateCode == '')
{
$this->form_validation->set_message('userConfirmError', 'Sorry you did not have a correct Activation Code.');
}
$userConfirmed = $this->users_model->confirm_user($activateCode);
if($userConfirmed){
$this->form_validation->set_message('userConfirmed', 'Thanks your account is now active you may login!');
}else{
$this->form_validation->set_message('userRecord', 'I am sorry we do not have any details with that Activation Code');
}
$data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
$data['pageTitle'] = "User Confirm";
$this->load->view('frontend/assets/header', $data);
$this->load->view('frontend/user_confirm', $data);
$this->load->view('frontend/assets/footer');
}
確認功能:
function confirm_user($activateCode)
{
//Selects the userID where the given URI activateCode = ?
$this->db->select('userID');
$this->db->from('users');
$this->db->where('userActiveCode', $activateCode);
$result = $this->db->get();
if($result->num_rows == 1) // If the above result is = 1 then update the userActive row else it will fail
{
$this->db->set('userActive', 1);
$this->db->where('userActiveCode', $activateCode);
return TRUE;
}else{
return FALSE;
}
核心型號:
function companyDetails()
{
static $details;
if(!$details)
{
$this->db->select('coreCompanyName, coreContactName, coreContactEmail');
$details = $this->db->get('core')->first_row();
}
return $details;
}
可以肯定地說,你在查看時回顯了表單錯誤..? – 2012-03-05 05:11:19
@Sudhir我已經包含了我的觀點。 – 2012-03-06 00:00:34