我需要在我的网站上编辑个人资料,但每当我点击编辑选项时我都会遇到问题。它将我重定向到在else语句中的登录表单,这意味着我的if语句不起作用,我不知道为什么。
我的模型代码工作得很好,这就是为什么我只上传控制器代码
控制器
function editprofileoverseas()
{
if($this->session->userdata('is_logged_in') == true)
{
$this->load->model('overseasmember_model');
$this->load->model('wings_model');
error_reporting(E_ALL ^ E_WARNING);
$this->load->helper('registration');
$this->data['title'] = "Register Member";
$checked_wings = $this->input->post('wings');
$this->form_validation->set_rules('firstname', 'Name', 'required');
//$this->form_validation->set_rules('lastname', 'Last Name', 'required');
$this->form_validation->set_rules('mobile', 'Mobile', 'required');
/* changes address */
$this->form_validation->set_rules('mailingaddress', 'Mailing Address', 'required');
$this->form_validation->set_rules('relation', 'Relation', 'required');
/* changes address */
$uploaddir = './profile_pics/';
$session_id = $this->session->userdata('id');
// changes
$cn = $this->input->post('hidden3');
$sessiondata101 = $this->session->all_userdata();
if($this->session->userdata('membershipno') == null && $this->session->userdata('birth_date') == null && $this->session->userdata('created') == '')
{
if($cn == "<span class='status-not-available'>CNIC already registered.</span>")
{
$this->form_validation->set_rules('cnic', 'CNIC', 'matches[confirmcnic]|is_unique[free_members.cnic]|is_unique[domestic_members.cnic]|is_unique[overseas_members.cnic]');
}
elseif($cn == "<span class='status-not-available'>Enter correct CNIC format.</span>")
{
$this->form_validation->set_rules('cnic', 'CNIC', 'matches[confirmcnic]|regex_match[/\d{5}\-\d{7}-\d{1}\]');
}
elseif($cn == "<span class='status-not-available'>CNIC is required.</span>")
{
$this->form_validation->set_rules('cnic', 'CNIC', 'required|matches[confirmcnic]');
}
else
{
$this->form_validation->set_rules('cnic', 'CNIC');
}
//$this->form_validation->set_rules('cnic', 'CNIC', 'required|matches[confirmcnic]|is_unique[free_members.cnic]|is_unique[domestic_members.cnic]|is_unique[overseas_members.cnic]');
$this->form_validation->set_rules('confirmcnic', 'CNIC Confirmation', 'required');
}
// changes
if ($this->form_validation->run() == true)
{
// changes
if($this->session->userdata('membershipno') == null && $this->session->userdata('birth_date') == null && $this->session->userdata('created') == '')
{
$data = array(
'first_name' => preg_replace('/\s+/', ' ', $this->input->post('firstname')),
'dob' => $this->input->post('dob'),
'mobile' => $this->input->post('mobile'),
'phone' => $this->input->post('phone'),
'country' => $this->input->post('hidden20'),
'province' => $this->input->post('hidden21'),
'city' => $this->input->post('hidden31'),
'continent' => $this->input->post('hidden32'),
'cnic' => $this->input->post('cnic'),
'membershipno' => $this->input->post('cnic'),
'created' => date('Y-m-d H:i:s'),
/* changes address */
'mailingaddress' => $this->input->post('mailingaddress'),
'relation' => $this->input->post('relation'),
/* changes address */
);
}
else{
$data = array(
'first_name' => preg_replace('/\s+/', ' ', $this->input->post('firstname')),
'dob' => $this->input->post('dob'),
'mobile' => $this->input->post('mobile'),
'phone' => $this->input->post('phone'),
'country' => $this->input->post('hidden20'),
'province' => $this->input->post('hiddenprovince'),
'city' => $this->input->post('hidden31'),
'continent' => $this->input->post('hidden32'),
'mailingaddress' => $this->input->post('mailingaddress'),
'relation' => $this->input->post('relation'),
);
}
// changes
}
if ($this->form_validation->run() == true)
{
$sessiondata10 = $this->session->all_userdata();
$data['id'] = $sessiondata10['id'];
$sessiondata10['first_name'] = $data['first_name'];
$sessiondata10['birth_date'] = $data['dob'];
$sessiondata10['mobile'] = $data['mobile'];
$sessiondata10['phone'] = $data['phone'];
$sessiondata10['country'] = $data['country'];
$sessiondata10['province'] = $data['province'];
$sessiondata10['city'] = $data['city'];
$sessiondata10['continent'] = $data['continent'];
/* changes address */
$sessiondata10['mailingaddress'] = $data['mailingaddress'];
$sessiondata10['relation'] = $data['relation'];
/* changes address */
// changes
if($this->session->userdata('membershipno') == null && $this->session->userdata('birth_date') == null && $this->session->userdata('created') == '')
{
$sessiondata10['cnic'] = $data['cnic'];
}
// changes
if($checked_wings > 0 && $sessiondata10['wingid'] != null){
$data3 = array();
foreach($_POST['check_list2'] as $item1){
if($item1 == "Commerce & Trade")
$data3['Commerce_Trade'] = 1;
if($item1 == "Other")
$data3['Other'] = $this->input->post('otherfield');
if($item1 == "Industry")
$data3['Industry'] = 1;
if($item1 == "Lawyer")
$data3['Lawyer'] = 1;
if($item1 == "Doctor")
$data3['Doctor'] = 1;
if($item1 == "Minorities")
$data3['Minorities'] = 1;
if($item1 == "Women_Development")
$data3['Women'] = 1;
if($item1 == "Functionary")
$data3['Functionary'] = 1;
}
$this->wings_model->updateMember($data3,$sessiondata10['wingid']);
}
elseif($checked_wings > 0 && $sessiondata10['wingid'] == null){
$data3 = array(
'memberid' => $sessiondata10['id'],
);
foreach($_POST['check_list2'] as $item1){
if($item1 == "Commerce & Trade")
$data3['Commerce_Trade'] = 1;
if($item1 == "Other")
$data3['Other'] = $this->input->post('otherfield');
if($item1 == "Industry")
$data3['Industry'] = 1;
if($item1 == "Lawyer")
$data3['Lawyer'] = 1;
if($item1 == "Doctor")
$data3['Doctor'] = 1;
if($item1 == "Minorities")
$data3['Minorities'] = 1;
if($item1 == "Women_Development")
$data3['Women'] = 1;
if($item1 == "Functionary")
$data3['Functionary'] = 1;
}
$id3 = $this->wings_model->addMemberWing($data3);
$data['wingid'] = $id3;
$sessiondata10['wingid'] = $data['wingid'];
}
$uploadfile = $uploaddir . basename($_FILES['myFile']['name']);
if(basename($_FILES['myFile']['name']) != NULL || basename($_FILES['myFile']['name'] != ''))
{
if(move_uploaded_file($_FILES['myFile']['tmp_name'], $uploadfile)){
$data['pic_path'] = $uploadfile;
$sessiondata10['pic_path'] = $uploadfile;
}else{
//echo "Possible file upload attack!\n";
}
}
else
$data['pic_path'] = $sessiondata10['pic_path'];
$this->overseasmember_model->updateMember($data,$session_id);
$data['is_logged_in'] = true;
$this->load->view('overseasmemberarea',$sessiondata10);
return;
}
else
{
// changes
$sessiondata1 = $this->session->all_userdata();
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->session->flashdata('message')));
$this->data['first_name'] = array(
'name' => 'firstname',
'id' => 'firstname',
'type' => 'text',
'class' => 'input-xlarge',
'onBlur' => 'checkAvailability2()',
'placeholder' => "",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('first_name'),
);
$this->data['relation'] = array(
'name' => 'relation',
'id' => 'relation',
'type' => 'text',
'class' => 'input-xlarge',
//'onBlur' => 'checkAvailability4()',
'placeholder' => "",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('relation'),
);
$this->data['dob'] = array(
'name' => 'dob',
'id' => 'dob',
'type' => 'text',
'class' => 'input-xlarge',
'onBlur' => 'checkDOB()',
'placeholder' => "DD-MM-YYYY",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('dob'),
);
$this->data['mobile'] = array(
'name' => 'mobile',
'id' => 'mobile',
'type' => 'text',
'class' => 'input-xlarge',
'onBlur' => 'checkMobile()',
'placeholder' => "03012345678",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('mobile'),
);
$this->data['phone'] = array(
'name' => 'phone',
'id' => 'phone',
'type' => 'tel',
'class' => 'input-xlarge',
'placeholder' => "",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('phone'),
);
/* changes address*/
$this->data['mailingaddress'] = array(
'name' => 'mailingaddress',
'id' => 'mailingaddress',
'type' => 'text',
//'class' => 'input-xlarge',
//'onBlur' => 'checkPs()',
'placeholder' => "",
'cols' => 50,
'rows' => 4,
'value' => $this->form_validation->set_value('mailingaddress'),
);
/* changes address*/
/* changes */
$this->data['cnic'] = array(
'name' => 'cnic',
'id' => 'cnic',
'type' => 'text',
'class' => 'input-xlarge',
'onBlur' => 'checkAvailability3()',
'placeholder' => "XXXXX-XXXXXXX-X",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('cnic'),
);
$this->data['confirmcnic'] = array(
'name' => 'confirmcnic',
'id' => 'confirmcnic',
'type' => 'text',
'class' => 'input-xlarge',
'onBlur' => 'checkAvailability3()',
'placeholder' => "XXXXX-XXXXXXX-X",
'size' => 32,
'maxlength' => 128,
'value' => $this->form_validation->set_value('confirmcnic'),
);
$sessiondata1['cnic'] = $this->data['cnic'];
$sessiondata1['confirmcnic'] = $this->data['confirmcnic'];
$sessiondata1['message'] = $this->data['message'];
$this->load->view('edit_profileoverseas',$sessiondata1);
}
}
else
$this->index();
}