1
我是Codeigniter的新手。請有人幫助我創建一個文件夾來存儲用戶信息在rgistration.Creating文件夾應該與註冊並行。這意味着登記和創建文件夾應該由單一的按鈕發生在註冊時爲用戶創建文件夾
THIS IS MY控制器
公共功能指數(){
$this->form_validation->set_rules('user_name', 'User Name', 'trim|required');
$this->form_validation->set_rules('confirm_password', 'Confirmed Password', 'trim|required');
//run validation on post data
if ($this->form_validation->run() == FALSE)
{ //validation fails
$this->load->view('Registration');
}
else
{
//insert the contact form data into database
$data = array(
'user_name' => $this->input->post('user_name'),
'confirm_password' => $this->input->post('confirm_password'),
);
$data1 = array(
'username' => $this->input->post('user_name'),
'password' =>md5 ($this->input->post('confirm_password')),
);
$this->db->insert('registration', $data);
if ($this->db->insert('users', $data1))
{
// success
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">We received your message! Will get back to you shortly!!!</div>');
redirect('Welcome/index');
}
else
{
// error
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Oops! Some Error. Please try again later!!!</div>');
//redirect('login/HomePage');
}
}
}
這是我的看法
<form class="well form-horizontal" action="<?php echo site_url('Registration/index'); ?>" method="post" id="contact_form">
<fieldset>
<!-- Form Name -->
<legend>Sign Up</legend>
<br /> <br />
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" name="user_name" placeholder="your email address" id="txtuser" class="form-control" >
<span class="input-group-btn">
<a href="javascript:void(0);" right id="chk_avail" class="btn btn-danger" role="button" >Check Availability</a>
</span>
</div>
<div id="msgbx_err" class="alert-box error"><span>error: </span>User already exist with same name.</div>
<div id="msgbx_success" class="alert-box success"><span>success: </span>Username available.</div>
</div>
<!-- Text input-->
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key" aria-hidden="true"></i></span>
<input name="user_password" placeholder="Password" class="form-control" type="password" id="pass1">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key" aria-hidden="true"></i></span>
<input class="form-control" placeholder="Confirm Password" type="password" name="confirm_password" id="pass2" onkeyup="checkPass(); return false;" required/>
</div>
<span id="confirmMessage" class="confirmMessage"></span>
</div>
<!-- Button -->
<button id="btn_login" name="btn_login" type="submit" class="btn btn-success center-block btn-sign-in" value="Sign In" > Sign In </button>
</fieldset>
</form>
對不起Yadhu先生,我不能明白,,我想知道如何從視圖發送用戶ID控制器,然後如何爲給定的用戶ID – Dushee
你有沒有做任何事情創建文件夾。然後將代碼粘貼到您的問題中 –
我做到了Mr.Yadhu' – Dushee