我是codeigniter的新手。请有人帮我创建一个文件夹来存储用户信息在rgistration.Creating文件夹应该与注册并行。这意味着注册和创建文件夹应该通过单个按钮
进行公共职能指数(){
$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>
答案 0 :(得分:0)
将mkdir用于create folder。在控制器中插入用户详细信息后立即使用它。
$this->db->insert('registration', $data);
$userName=$this->input->post('user_name'),
mkdir("/".$userName);