Codeigniter update records error - php

I am using codeigniter framework, and I keep getting this error when I submit my from to post to my database.
Controller
public function profilePic()
{
if ($this->session->userdata('userLogin')) {
$user_id = $this->session->userdata('user_id');
$data = array();
if (isset($_POST['add'])) {
$pic = $this->input->post('profileFace');
$front = $this->input->post('frontView');
$left = $this->input->post('leftView');
$right = $this->input->post('rightView');
$back = $this->input->post('backView');
$updtResult = $this->main_model->updateProfilePic($pic,$front,$left,$right,$back,$user_id);
redirect("userProfile");
} else {
$data['userdata'] = $this->main_model->getUserData();
$this->load->view("frontend/ajax-view", $data);
}
} else {
redirect("/fitness");
}
}
Model
function updateProfilePic($pic,$front,$left,$right,$back,$user_id) {
$check = $this->getUserData();
if(count($check)!=0)
{
if($pic != "")
{
$data['image'] = $pic;
}
if($front != "")
{
$data['front_view'] = $front;
}
if($left != "")
{
$data['left_view'] = $left;
}
if($right != "")
{
$data['right_view'] =$right;
}
if($back != "")
{
$data['back_view'] = $back;
}
// pr($data);
$this->db->where('user_id',$user_id);
$result = $this->db->update('fitness_users', $data);
}
return $result;
}
and the error i am getting is:

You can use set method to update your data and check your variable is set or not using isset()
if (isset($pic) && $pic != "") {
$this->db->set("image", $pic);
}
if (isset($front) && $front != "") {
$this->db->set("front_view", $front);
}
if (isset($left) && $left != "") {
$this->db->set("left_view", $left);
}
if (isset($right) && $right != "") {
$this->db->set("right_view", $right);
}
if (isset($back) && $back != "") {
$this->db->set("back_view", $back);
}
// pr($data);
$this->db->where('user_id', $user_id);
$result = $this->db->update('fitness_users');

Related

PHP strpos dont works properly(Path Generator)

I wanted to create a function that generates an image path from an array.The function has one argument and that argument is for you to decide from which folder you want to choose images.
So I have 90 elements in an array and each element is a path.Now I don't want a .png image so I wanted to create something like this(but it didn't work for me):
public function getRandomPath($RoboticOrArenag)
{
if ($RoboticOrArenag == 'Robotic' || $RoboticOrArenag == 'robotic') {
$countofarray = count($this->allImagesRobotic);
} else if ($RoboticOrArenag == 'Arenag' || $RoboticOrArenag == 'arenag') {
$countofarray = count($this->allImagesArenag);
} else {
$RoboticOrArenag = 0;
}
$randomNumber = rand(0, $countofarray);
if ($RoboticOrArenag == 'Robotic' || $RoboticOrArenag == 'robotic') {
if($randomNumber==50){
$randomNumber--;
}
else if ($randomNumber==0){
$randomNumber++;
}
$randomNumberPath = $this->allImagesRobotic[$randomNumber];
} else if ($RoboticOrArenag == 'Arenag' || $RoboticOrArenag == 'arenag') {
if($randomNumber==33){
$randomNumber--;
}
else if ($randomNumber==0){
$randomNumber++;
}
$randomNumberPath = $this->allImagesArenag[$randomNumber];
while(strpos($randomNumberPath, '.png') == true){
$randomNumber = rand(0, $countofarray);
$randomNumberPath = $this->allImagesArenag[$randomNumber];
}
} else {
$randomNumberPath = 0;
}
$randomPath = "/img/$RoboticOrArenag/$randomNumberPath";
return $randomPath;
}

How to Auto Login and Redirect After Registration in opencart

I am using opencart 2.0 and i have made custom registeration page in opencart.After successful registration i am redirecting to myaccount page but it will redirect to login page.
Can anybody help me in this to sort out the problem?
Here's my controller code :-
public function register() {
$this->load->language('checkout/checkout');
$json = array();
//if (!$json) {
$this->load->model('account/customer');
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
/*if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$json['error']['lastname'] = $this->language->get('error_lastname');
}*/
if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/', $this->request->post['email'])) {
$json['error']['email'] = $this->language->get('error_email');
}
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$json['error']['warning'] = $this->language->get('error_exists');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
/*if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) {
$json['error']['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['country_id'] == '') {
$json['error']['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}*/
if ((utf8_strlen($this->request->post['password']) < 4) || (utf8_strlen($this->request->post['password']) > 20)) {
$json['error']['password'] = $this->language->get('error_password');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$json['error']['confirm'] = $this->language->get('error_confirm');
}
/*if ($this->config->get('config_account_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
} */
// Customer Group
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
foreach ($custom_fields as $custom_field) {
if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) {
$json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
}
}
//}
//if (!$json) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->session->data['account'] = 'register';
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
/*if ($customer_group_info && !$customer_group_info['approval']) {
$this->customer->login($this->request->post['email'], $this->request->post['password']);
// Default Payment Address
$this->load->model('account/address');
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
if (!empty($this->request->post['shipping_address'])) {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
} else {*/
$json['redirect'] = $this->url->link('account/account');
//}
unset($this->session->data['guest']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
// Add to activity log
$this->load->model('account/activity');
$activity_data = array(
'customer_id' => $customer_id,
'name' => $this->request->post['firstname'] . ' ' . $this->request->post['lastname']
);
$this->model_account_activity->addActivity('register', $activity_data);
//}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}

Why base64_encode() return null

I have a 22M docx file and want to encode it using base64_encode() function in php. But It always returns NULL value after running this function. Is there any limit file size or condition for this function. My code:
$handle = fopen($fullpathfile, "rb");
$imagestr = base64_encode(fread($handle, filesize($fullpathfile)));
fclose($handle);
Try this code
$fh = fopen($fullpathfile, 'rb');
$cache = '';
$eof = false;
while (1) {
if (!$eof) {
if (!feof($fh)) {
$row = fgets($fh, 4096);
} else {
$row = '';
$eof = true;
}
}
if ($cache !== '')
$row = $cache.$row;
elseif ($eof)
break;
$b64 = base64_encode($row);
$put = '';
if (strlen($b64) < 76) {
if ($eof) {
$put = $b64."\n";
$cache = '';
} else {
$cache = $row;
}
} elseif (strlen($b64) > 76) {
do {
$put .= substr($b64, 0, 76)."\n";
$b64 = substr($b64, 76);
} while (strlen($b64) > 76);
$cache = base64_decode($b64);
} else {
if (!$eof && $b64{75} == '=') {
$cache = $row;
} else {
$put = $b64."\n";
$cache = '';
}
}
if ($put !== '') {
echo $put;
}
}
fclose($fh);

Including already existing variable in a function

Im trying to make a function, that takes an input, determines its value, and outputs a word from an already existing array that has been included in the script. The problem is the output is blank, i believe the function ignores variables already in the script, is there a way to change this so existing variables arent ignored by the function?
Here is the function:
The words need to be from an array because of multi-lingual requirements.
function get_genre($id)
{
if($id == "1"){
$genre = $lang['277'];
}
if($id == "2"){
$genre = $lang['278'];
}
if($id == "3"){
$genre = $lang['279'];
}
if($id == "4"){
$genre = $lang['280'];
}
if($id == "5"){
$genre = $lang['281'];
}
if($id == "6"){
$genre = $lang['282'];
}
if($id == "7"){
$genre = $lang['283'];
}
if($id == "8"){
$genre = $lang['284'];
}
if($id == "9"){
$genre = $lang['285'];
}
if($id == "10"){
$genre = $lang['286'];
}
if($id == "11"){
$genre = $lang['287'];
}
if($id == "12"){
$genre = $lang['288'];
}
if($id == "13"){
$genre = $lang['289'];
}
if($id == "14"){
$genre = $lang['290'];
}
if($id == "15"){
$genre = $lang['374'];
}
return $genre;
}
function get_genre($id)
{
global $lang;
....
}
or
function get_genre($id, $lang) //Must pass $lang array to function here
{
}
function get_genre($id)
{
global $lang;
if($id == "1"){
$genre = $lang['277'];
}
if($id == "2"){
$genre = $lang['278'];
}
if($id == "3"){
$genre = $lang['279'];
}
if($id == "4"){
$genre = $lang['280'];
}
if($id == "5"){
$genre = $lang['281'];
}
if($id == "6"){
$genre = $lang['282'];
}
if($id == "7"){
$genre = $lang['283'];
}
if($id == "8"){
$genre = $lang['284'];
}
if($id == "9"){
$genre = $lang['285'];
}
if($id == "10"){
$genre = $lang['286'];
}
if($id == "11"){
$genre = $lang['287'];
}
if($id == "12"){
$genre = $lang['288'];
}
if($id == "13"){
$genre = $lang['289'];
}
if($id == "14"){
$genre = $lang['290'];
}
if($id == "15"){
$genre = $lang['374'];
}
return $genre;
}
While this isn't ideal, have you considered using an associative array?
var $lookupArray = array();
$lookupArray["1"] = $lang['274'];
....
Then you can call it like this:
function get_genre($id)
{
return(array_key_exists($id,$lookupArray)) ? $lookupArray[$id] : null;
}

Form's data can not post (Codeigniter)

i am working on Codigniter,i have a issue with posting form's data..
in my form,there is different section,i have put array for that different section
Here is my code (Controller)
<?php
class Resume extends CI_Controller{
var $user_id;
function __construct(){
parent::__construct();
$this->user_id = $this->session->userdata('user_id');
$this->load->model("Resume_model");
if($this->session->userdata('user_id') == NULL){
redirect('user/login','refresh');
}
}
public function index(){
$this->Resume();
}
public function Resume(){
if($this->input->post('Skills')){
$Resume = $this->input->post();
$ResumeInsert=array();
$ResumeUpdate=array();
$Key_Resume__ExistIDs=array();
foreach($this->input->post('Person_id') as $key =>$value ){
$ResumeInsert[$key]['updated'] = Date("Y-m-d");
$ResumeInsert[$key]['Importance_JK'] = $Resume['Importance_JK'];
$ResumeInsert[$key]['user_FK'] = $user_id;
$ResumeInsert[$key]['Person_id'] = $Resume['Person_id'][$key];
$ResumeInsert[$key]['email_contact'] = $Resume['email_contact'][$key];
$ResumeInsert[$key]['Contact_Phone'] = $Resume['Contact_Phone'][$key];
$ResumeInsert[$key]['communication'] = $Resume['communication'][$key];
$ResumeInsert[$key]['creativity'] = $Resume['creativity'][$key];
$ResumeInsert[$key]['team_work'] = $Resume['team_work'][$key];
$ResumeInsert[$key]['organizational'] = $Resume['organizational'][$key];
$ResumeInsert[$key]['Leadership'] = $Resume['Leadership'][$key];
$ResumeInsert[$key]['Productivity'] = $Resume['Productivity'][$key];
$ResumeInsert[$key]['Postal_Address'] = $Resume['Postal_Address'][$key];
$ResumeInsert[$key]['Career_objective'] = $Resume['Career_objective'][$key];
}
foreach($this->input->post('emp_id') as $key =>$value ){
$ResumeInsert[$key]['resume_keyid'] = $Resume['emp_id'][$key];
$ResumeInsert[$key]['employer_name'] = $Resume['employer_name'][$key];
$ResumeInsert[$key]['start_Date'] = $Resume['start_Date'][$key];
$ResumeInsert[$key]['end_date'] = $Resume['end_date'][$key];
$ResumeInsert[$key]['type_id'] = $Resume['type_id'][$key];
$ResumeInsert[$key]['position'] = $Resume['position'][$key];
$ResumeInsert[$key]['responsibility'] = $Resume['responsibility'][$key];
$ResumeInsert[$key]['Skills'] = $Resume['Skills'][$key];
print_r ($ResumeInsert);exit;
}
foreach($this->input->post('resume_id1') as $key =>$value ){
$ResumeInsert[$key]['edu_id'] = $Resume['resume_id1'][$key];
$ResumeInsert[$key]['year_gain'] = $Resume['year_gain'][$key];
$ResumeInsert[$key]['qualification_name'] = $Resume['qualification_name'][$key];
$ResumeInsert[$key]['institution_name'] = $Resume['institution_name'][$key];
$ResumeInsert[$key]['outstanding_Ach'] = $Resume['outstanding_Ach'][$key];
$ResumeInsert[$key]['aquired_skill'] = $Resume['aquired_skill'][$key];
$ResumeInsert[$key]['expiry'] = $Resume['expiry'][$key];
$ResumeInsert[$key]['Application_of_Skill'] = $Resume['Application_of_Skill'][$key];
}
foreach($this->input->post('resume_id2') as $key =>$value ){
$ResumeInsert[$key]['resume_skillID'] = $Resume['resume_id2'][$key];
$ResumeInsert[$key]['skill_name'] = $Resume['skill_name'][$key];
$ResumeInsert[$key]['Licences_permits'] = $Resume['Licences_permits'][$key];
$ResumeInsert[$key]['date_Achived'] = $Resume['date_Achived'][$key];
$ResumeInsert[$key]['expiry_renewal'] = $Resume['expiry'][$key];
$ResumeInsert[$key]['skill_work'] = $Resume['application_of_skill'][$key];
$ResumeInsert[$key]['course_tilte'] = $Resume['course_tilte'][$key];
}
foreach($this->input->post('resume_id3') as $key =>$value ){
$ResumeInsert[$key]['hobbyId'] = $Resume['resume_id3'][$key];
$ResumeInsert[$key]['hobby_name'] = $Resume['hobby_name'][$key];
$ResumeInsert[$key]['achievement_name'] = $Resume['achievement_name'][$key];
$ResumeInsert[$key]['Application_OF_hobby_work'] = $Resume['Application_of_Skill'][$key];
}
foreach($this->input->post('resume_id4') as $key =>$value ){
$ResumeInsert[$key]['ref_resume_ID'] = $Resume['resume_id4'][$key];
$ResumeInsert[$key]['referee_name'] = $Resume['referee_name'][$key];
$ResumeInsert[$key]['Position_referee'] = $Resume['Position'][$key];
$ResumeInsert[$key]['company_name_ref'] = $Resume['company_name'][$key];
$ResumeInsert[$key]['phone_ref'] = $Resume['phone_ref'][$key];
$ResumeInsert[$key]['contact_email_ref'] = $Resume['contact_email'][$key];
$ResumeInsert[$key]['reference_Type'] = $Resume['reference_Type'][$key];
$ResumeInsert[$key]['Application_of_Skill_ref'] = $Resume['Application_of_Skill'][$key];
}
foreach($this->input->post('resume_id5') as $key =>$value ){
$ResumeInsert[$key]['Application_Id'] = $Resume['resume_id5'][$key];
$ResumeInsert[$key]['app_date_sent'] = $Resume['date_sent'][$key];
$ResumeInsert[$key]['app_busisness_name'] = $Resume['app_busisness_name'][$key];
$ResumeInsert[$key]['app_address'] = $Resume['app_address'][$key];
$ResumeInsert[$key]['app_contact_phone'] = $Resume['app_contact_phone'][$key];
$ResumeInsert[$key]['app_outcome'] = $Resume['app_outcome'][$key];
$ResumeInsert[$key]['app_date_closed'] = $Resume['app_date_closed'][$key];
}
if(isset($Resume['id'][$key]))
{
// echo "test";exit;
$Key_Resume__ExistIDs[]=$Resume['id'][$key];
if( $ResumeInsert[$key]['Person_id'] != ""){
$ResumeUpdate[$key]['Person_id'] = $ResumeInsert[$key]['Person_id'];
}
if( $ResumeInsert[$key]['email_contact'] != ""){
$ResumeUpdate[$key]['email_contact'] = $ResumeInsert[$key]['email_contact'];
}
if( $ResumeInsert[$key]['Contact_Phone'] != ""){
$ResumeUpdate[$key]['Contact_Phone'] = $ResumeInsert[$key]['Contact_Phone'];
}
if( $ResumeInsert[$key]['communication'] != ""){
$ResumeUpdate[$key]['communication'] = $ResumeInsert[$key]['communication'];
}
if( $ResumeInsert[$key]['creativity'] != ""){
$ResumeUpdate[$key]['creativity'] = $ResumeInsert[$key]['creativity'];
}
if( $ResumeInsert[$key]['team_work'] != ""){
$ResumeUpdate[$key]['team_work'] = $ResumeInsert[$key]['team_work'];
}
if( $ResumeInsert[$key]['organizational'] != ""){
$ResumeUpdate[$key]['organizational'] = $ResumeInsert[$key]['organizational'];
}
if( $ResumeInsert[$key]['Leadership'] != ""){
$ResumeUpdate[$key]['Leadership'] = $ResumeInsert[$key]['Leadership'];
}
if( $ResumeInsert[$key]['Productivity'] != ""){
$ResumeUpdate[$key]['Productivity'] = $ResumeInsert[$key]['Productivity'];
}
if( $ResumeInsert[$key]['Postal_Address'] != ""){
$ResumeUpdate[$key]['Postal_Address'] = $ResumeInsert[$key]['Postal_Address'];
}
if( $ResumeInsert[$key]['Career_objective'] != ""){
$ResumeUpdate[$key]['Career_objective'] = $ResumeInsert[$key]['Career_objective'];
}
if( $ResumeInsert[$key]['resume_keyid'] != ""){
$ResumeUpdate[$key]['resume_keyid'] = $ResumeInsert[$key]['resume_keyid'];
}
if( $ResumeInsert[$key]['employer_name'] != ""){
$ResumeUpdate[$key]['employer_name'] = $ResumeInsert[$key]['employer_name'];
}
if( $ResumeInsert[$key]['start_Date'] != ""){
$ResumeUpdate[$key]['start_Date'] = $ResumeInsert[$key]['start_Date'];
}
if( $ResumeInsert[$key]['end_date'] != "") {
$ResumeUpdate[$key]['end_date'] = $ResumeInsert[$key]['end_date'];
}
if( $ResumeInsert[$key]['type_id'] != ""){
$ResumeUpdate[$key]['type_id'] = $ResumeInsert[$key]['type_id'];
}
if( $ResumeInsert[$key]['position'] != ""){
$ResumeUpdate[$key]['position'] = $ResumeInsert[$key]['position'];
}
if( $ResumeInsert[$key]['edu_id'] != ""){
$ResumeUpdate[$key]['edu_id'] = $ResumeInsert[$key]['edu_id'];
}
if( $ResumeInsert[$key]['year_gain'] != ""){
$ResumeUpdate[$key]['year_gain'] = $ResumeInsert[$key]['year_gain'];
}
if( $ResumeInsert[$key]['qualification_name'] != ""){
$ResumeUpdate[$key]['qualification_name'] = $ResumeInsert[$key]['qualification_name'];
}
if( $ResumeInsert[$key]['institution_name'] != ""){
$ResumeUpdate[$key]['institution_name'] = $ResumeInsert[$key]['institution_name'];
}
if( $ResumeInsert[$key]['outstanding_Ach'] != ""){
$ResumeUpdate[$key]['outstanding_Ach']= $ResumeInsert[$key]['outstanding_Ach'];
}
if( $ResumeInsert[$key]['aquired_skill'] != ""){
$ResumeUpdate[$key]['aquired_skill'] = $ResumeInsert[$key]['aquired_skill'];
}
if( $ResumeInsert[$key]['expiry'] != ""){
$ResumeUpdate[$key]['expiry'] = $ResumeInsert[$key]['expiry'];
}
if( $ResumeInsert[$key]['Application_of_Skill'] != ""){
$ResumeUpdate[$key]['Application_of_Skill'] = $ResumeInsert[$key]['Application_of_Skill'];
}
if( $ResumeInsert[$key]['resume_skillID'] != ""){
$ResumeUpdate[$key]['resume_skillID'] = $ResumeInsert[$key]['resume_skillID'];
}
if( $ResumeInsert[$key]['skill_name'] != ""){
$ResumeUpdate[$key]['skill_name'] = $ResumeInsert[$key]['skill_name'];
}
if( $ResumeInsert[$key]['Licences_permits'] != ""){
$ResumeUpdate[$key]['Licences_permits'] = $ResumeInsert[$key]['Licences_permits'];
}
if( $ResumeInsert[$key]['date_Achived'] != ""){
$ResumeUpdate[$key]['date_Achived'] = $ResumeInsert[$key]['date_Achived'];
}
if( $ResumeInsert[$key]['expiry_renewal'] !="") {
$ResumeUpdate[$key]['expiry_renewal'] = $ResumeInsert[$key]['expiry_renewal'];
}
if( $ResumeInsert[$key]['skill_work'] != ""){
$ResumeUpdate[$key]['skill_work'] = $ResumeInsert[$key]['skill_work'];
}
if( $ResumeInsert[$key]['course_tilte'] != ""){
$ResumeUpdate[$key]['course_tilte'] = $ResumeInsert[$key]['course_tilte'];
}
if( $ResumeInsert[$key]['hobbyId'] != ""){
$ResumeUpdate[$key]['hobbyId'] = $ResumeInsert[$key]['hobbyId'];
}
if( $ResumeInsert[$key]['hobby_name'] != ""){
$ResumeUpdate[$key]['hobby_name'] = $ResumeInsert[$key]['hobby_name'];
}
if( $ResumeInsert[$key]['achievement_name'] != ""){
$ResumeUpdate[$key]['achievement_name'] = $ResumeInsert[$key]['achievement_name'];
}
if( $ResumeInsert[$key]['Application_OF_hobby_work'] != ""){
$ResumeUpdate[$key]['Application_OF_hobby_work'] = $ResumeInsert[$key]['Application_OF_hobby_work'];
}
if( $ResumeInsert[$key]['ref_resume_ID'] != ""){
$ResumeUpdate[$key]['ref_resume_ID'] = $ResumeInsert[$key]['ref_resume_ID'];
}
if( $ResumeInsert[$key]['referee_name'] != ""){
$ResumeUpdate[$key]['referee_name'] = $ResumeInsert[$key]['referee_name'];
}
if( $ResumeInsert[$key]['Position_referee'] != ""){
$ResumeUpdate[$key]['Position_referee'] = $ResumeInsert[$key]['Position_referee'];
}
if( $ResumeInsert[$key]['company_name_ref'] != ""){
$ResumeUpdate[$key]['company_name_ref'] = $ResumeInsert[$key]['company_name_ref'];
}
if( $ResumeInsert[$key]['phone_ref'] != ""){
$ResumeUpdate[$key]['phone_ref'] = $ResumeInsert[$key]['phone_ref'];
}
if( $ResumeInsert[$key]['contact_email_ref'] != ""){
$ResumeUpdate[$key]['contact_email_ref'] = $ResumeInsert[$key]['contact_email_ref'];
}
if( $ResumeInsert[$key]['reference_Type'] != ""){
$ResumeUpdate[$key]['reference_Type'] = $ResumeInsert[$key]['reference_Type'];
}
if( $ResumeInsert[$key]['Application_of_Skill_ref'] != ""){
$ResumeUpdate[$key]['Application_of_Skill_ref'] = $ResumeInsert[$key]['Application_of_Skill_ref'];
}
if( $ResumeInsert[$key]['app_date_sent'] != ""){
$ResumeUpdate[$key]['app_date_sent'] = $ResumeInsert[$key]['app_date_sent'];
}
if( $ResumeInsert[$key]['Application_Id'] != ""){
$ResumeUpdate[$key]['Application_Id'] = $ResumeInsert[$key]['Application_Id'];
}
if( $ResumeInsert[$key]['app_busisness_name'] != ""){
$ResumeUpdate[$key]['app_busisness_name'] = $ResumeInsert[$key]['app_busisness_name'];
}
if( $ResumeInsert[$key]['app_address'] != ""){
$ResumeUpdate[$key]['app_address'] = $ResumeInsert[$key]['app_address'];
}
if( $ResumeInsert[$key]['app_contact_phone'] != "")
{
$ResumeUpdate[$key]['app_contact_phone'] = $ResumeInsert[$key]['app_contact_phone'];
}
if( $ResumeInsert[$key]['app_outcome'] != ""){
$ResumeUpdate[$key]['app_outcome'] = $ResumeInsert[$key]['app_outcome'];
}
if( $ResumeInsert[$key]['app_date_closed'] != ""){
$ResumeUpdate[$key]['app_date_closed'] = $ResumeInsert[$key]['app_date_closed'];
}
if( $ResumeInsert[$key]['resume_id'] != ""){
$ResumeUpdate[$key]['resume_id'] = $ResumeInsert[$key]['resume_id'];
}
$ResumeUpdate[$key]['resume_id']=$Resume['id'][$key];
unset($ResumeInsert[$key]);
}
else{
$ResumeInsert[$key]['resume_id'] = $GetLastID;
$GetLastID++;
}
$status=$this->Resume_model->ProcessData($idsToDelete,$ResumeUpdate,$user_id,$ResumeInsert,$imgInsert,$imgUpdate);
redirect('Resume','refresh');
}
}
?>
Here the insert query (model)
function ProcessData($tbl_resumeInsert){
if(!empty($tbl_resumeInsert))
{
$this->insert_tbl_resume($user_id,$tbl_resumeInsert);
}
}
function insert_tbl_resume($id,$arrtbl_resume)
{
$this->db->insert_batch('tbl_resume', $arrtbl_resume);
}
in above code,when im going to submit the form only first Foreach loop's data can insert,when i print $ResumeInsert,it shows me only first foreach loop's data foreach($this->input->post('Person_id') as $key =>$value )
Rest foreach loop's data appears NULL in DB
please any help?
Thank You!
The function $this->input->post('something') is returning a value from the $_POST array with a key of 'something'. If the key 'something' does not exist it returns NULL. (or FALSE in CI version < 3.0)
$_POST is an associative array and will have at most only one item with any given key. So the code
foreach($this->input->post('Person_id') as $key =>$value )
{
...
will only run once as there is only one $_POST array item with the key 'Person_id'.
If your form html has more than one field named 'Person_id' only the value from the last field will be posted to the server.

Categories