Getting error while uploading image and files in CodeIgniter - php

I have created an employee registration form but I'm getting errors in image uploading and storing in the image folder and also getting errors in document file uploading. and errors like
Error Number: 1048
Column 'resume' cannot be null
INSERT INTO add_employee (photograph, name, date_of_birth, date_of_joining, designation, qualification, Blood_Group, exp_before_joining, exp_after_joining, total_exp, permanent_address, correspondance_address, resume, education_certificate, experience_certificate, id_proof, address_proof, contact, emergency_contact, emergency_contact_person) VALUES ('', 'xxx', '2021-04-10', '2021-04-10', 'Production', 'MCA', 'O+ve', '4', '4', '4', 'asdfgh \r\n ', ' hjghjfghdgfd,ghfchhf\r\n ', NULL, NULL, NULL, NULL, NULL, '6754321234', '6789557890', 'xzxz')
Filename: C:/xampp/htdocs/maheshfoundation/system/database/DB_driver.php
Line Number: 691
my view file
<?php echo form_open_multipart('employee/store');?>
<div class="row">
<div class="col-3">
<div class="form-group">
<label for="photograph">Photograph</label>
<input type="file" class="form-control" name="photograph" id="photograph" placeholder="Choose file" required>
<small><?php echo form_error('photograph'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="name">Enter Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Name" required>
<small><?php echo form_error('name'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="date_of_birth">Date of Birth</label>
<input type="date" class="form-control" name="date_of_birth" id="date_of_birth" placeholder="DOB" required>
<small><?php echo form_error('date_of_birth'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="date_of_joining">Date of Joining</label>
<input type="date" class="form-control" name="date_of_joining" id="date_of_joining" placeholder="DOJ" required>
<small><?php echo form_error('date_of_joining'); ?></small>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<div class="form-group">
<label for="designation">Designation</label>
<select class="form-control" name="designation" id="designation" required>
<option value="select">---Select---</option>
<option value="Marketing">Marketing</option>
<option value="Design">Design</option>
<option value="Super Admin">Super Admin</option>
<option value="Purchase">Purchase</option>
<option value="Planning">Planning</option>
<option value="Production">Production</option>
<option value="Quality">Quality</option>
<option value="Stores">Stores</option>
<option value="Management">Management</option>
<option value="HR">HR</option>
</select>
<small><?php echo form_error('designation'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="qualification">Qualification</label>
<input type="text" class="form-control" name="qualification" id="qualification" placeholder="Enter qualification" required>
<small><?php echo form_error('qualification'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="Blood Group">Blood Group</label>
<input type="text" class="form-control" name="Blood_Group" id="Blood_Group" placeholder="Enter Blood Group" required>
<small><?php echo form_error('Blood_Group'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="exp_before_joining">Experience Before Joining</label>
<input type="number" class="form-control" name="exp_before_joining" id="exp_before_joining" placeholder="Enter Experience Before Joining" required>
<small><?php echo form_error('exp_before_joining'); ?></small>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<div class="form-group">
<label for="exp_after_joining">Experience After Joining</label>
<input type="number" class="form-control" name="exp_after_joining" id="exp_after_joining" placeholder="Enter Experience After Joining" required>
<small><?php echo form_error('exp_after_joining'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="total_exp">Total Experience</label>
<input type="text" class="form-control" name="total_exp" id="total_exp" placeholder="Enter Total Experience" required>
<small><?php echo form_error('total_exp'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="Permanent_Address">Permanent Address *</label>
<textarea class="form-control" id="permanent_address" name="permanent_address" rows="4" cols="50" required>
</textarea>
<small><?php echo form_error('permanent_address'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="Correspondance_Address">Correspondance Address</label>
<textarea class="form-control" id="correspondance_address" name="correspondance_address" rows="4" cols="50" required>
</textarea>
<small><?php echo form_error('correspondance_address'); ?></small>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<div class="form-group">
<label for="resume">Resume</label>
<input type="file" class="form-control" name="resume" id="resume" placeholder="Choose file" required>
<small><?php echo form_error('resume'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="Education_Certificate">Education Certificate</label>
<input type="file" class="form-control" name="education_certificate" id="education_certificate" placeholder="Enter Name" required>
<small><?php echo form_error('education_certificate'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="Experience_Certificate">Experience Certificate</label>
<input type="file" class="form-control" name="experience_certificate" id="experience_certificate" placeholder="DOB" required>
<small><?php echo form_error('experience_certificate'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="id_proof">ID Proof *</label>
<input type="file" class="form-control" name="id_proof" id="id_proof" placeholder="DOJ" required>
<small><?php echo form_error('id_proof'); ?></small>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<div class="form-group">
<label for="Address_Proof">Address Proof</label>
<input type="file" class="form-control" name="address_proof" id="address_proof" placeholder="Choose file" required>
<small><?php echo form_error('address_proof'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="contact">Permanent Contact Number *</label>
<input type="text" class="form-control" name="contact" id="contact" placeholder="Enter Permanent Contact Number" required>
<small><?php echo form_error('contact'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="emergency_contact">Emergency Contact Number</label>
<input type="text" class="form-control" name="emergency_contact" id="emergency_contact" placeholder="Enter Emergency Contact Number" required>
<small><?php echo form_error('emergency_contact'); ?></small>
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="emergency_contact_person">Emergency Contact Person Name ?</label>
<input type="text" class="form-control" name="emergency_contact_person" id="emergency_contact_person" placeholder="Enter Emergency Contact Person Name" required>
<small><?php echo form_error('emergency_contact_person'); ?></small>
</div>
</div>
</div>
<button type="submit" value="submit" class="btn btn-primary">Submit</button>
<button type="reset" value="reset" class="btn btn-primary">Reset</button>
my controller file
public function store()
{
$photograph = $this->input->POST('photograph');
$name = $this->input->POST('name');
$date_of_birth = $this->input->POST('date_of_birth');
$date_of_joining = $this->input->POST('date_of_joining');
$designation = $this->input->POST('designation');
$qualification = $this->input->POST('qualification');
$Blood_Group = $this->input->POST('Blood_Group');
$exp_before_joining = $this->input->POST('exp_before_joining');
$exp_after_joining = $this->input->POST('exp_after_joining');
$total_exp = $this->input->POST('total_exp');
$permanent_address = $this->input->POST('permanent_address');
$correspondance_address = $this->input->POST('correspondance_address');
$resume = $this->input->POST('resume');
$education_certificate = $this->input->POST('education_certificate');
$experience_certificate = $this->input->POST('experience_certificate');
$id_proof = $this->input->POST('id_proof');
$address_proof = $this->input->POST('address_proof');
$contact = $this->input->POST('contact');
$emergency_contact = $this->input->POST('emergency_contact');
$emergency_contact_person = $this->input->POST('emergency_contact_person');
$configUpload['upload_path'] = 'images/'; #the folder placed in the root of project
$configUpload['allowed_types'] = 'gif|jpg|png|bmp|jpeg'; #allowed types description
$configUpload['max_size'] = '0'; #max size
$configUpload['max_width'] = '0'; #max width
$configUpload['max_height'] = '0'; #max height
$configUpload['encrypt_name'] = TRUE; #encrypt name of the uploaded file
$this->load->library('upload', $configUpload); #init the upload class
if (!$this->upload->do_upload())
{
$uploadedDetails = $this->upload->display_errors();
}
else
{
$uploadedDetails = $this->upload->data();
}
$emp_filename = $this->upload->data('file_name');
//print_r($uploadedDetails);
// // die;
echo "<br><br>";
$data = array(
'photograph' => $emp_filename,
'name' => $name,
'date_of_birth' => $date_of_birth,
'date_of_joining' => $date_of_joining,
'designation' => $designation,
'qualification' => $qualification,
'Blood_Group' => $Blood_Group,
'exp_before_joining' => $exp_before_joining,
'exp_after_joining' => $exp_after_joining,
'total_exp' => $total_exp,
'permanent_address' => $permanent_address,
'correspondance_address' => $correspondance_address,
'resume' => $resume,
'education_certificate' => $education_certificate,
'experience_certificate' => $experience_certificate,
'id_proof' => $id_proof,
'address_proof' => $address_proof,
'contact' => $contact,
'emergency_contact' => $emergency_contact,
'emergency_contact_person' => $emergency_contact_person
);
$this->load->model('EmployeeModel','emp');
$this->emp->insertEmployee($data);
redirect(base_url('add'));
}
my model file
public function insertEmployee($data)
{
return $this->db->insert('add_employee', $data);
}

Related

form in codeigniter cannot submit in controller

i have a problem regarding with form submission in my code. I have a form that would let the user to input his/her whole information profile and also in my form, i got dynamic input type boxes. In short i have a very large form in my html with JavaScript dynamic input type.
Now my problem is, i am printing the data submitted in my form from view to controller and it doesn't print anything or when i press submit button, the page only refreshes not submitting to the controller.
Here is my full view code:
<form name="Register" class="m-t" role="form" action="<?php echo site_url("user_login/register_user/reg_new") ?>" method="post">
<div class="container">
<div class="picture-container">
<div class="picture">
<img src="https://lh3.googleusercontent.com/LfmMVU71g-HKXTCP_QWlDOemmWg4Dn1rJjxeEsZKMNaQprgunDTtEuzmcwUBgupKQVTuP0vczT9bH32ywaF7h68mF-osUSBAeM6MxyhvJhG6HKZMTYjgEv3WkWCfLB7czfODidNQPdja99HMb4qhCY1uFS8X0OQOVGeuhdHy8ln7eyr-6MnkCcy64wl6S_S6ep9j7aJIIopZ9wxk7Iqm-gFjmBtg6KJVkBD0IA6BnS-XlIVpbqL5LYi62elCrbDgiaD6Oe8uluucbYeL1i9kgr4c1b_NBSNe6zFwj7vrju4Zdbax-GPHmiuirf2h86eKdRl7A5h8PXGrCDNIYMID-J7_KuHKqaM-I7W5yI00QDpG9x5q5xOQMgCy1bbu3St1paqt9KHrvNS_SCx-QJgBTOIWW6T0DHVlvV_9YF5UZpN7aV5a79xvN1Gdrc7spvSs82v6gta8AJHCgzNSWQw5QUR8EN_-cTPF6S-vifLa2KtRdRAV7q-CQvhMrbBCaEYY73bQcPZFd9XE7HIbHXwXYA=s200-no" class="picture-src" id="wizardPicturePreview" title="">
<input type="file" name="employee-picture" id="wizard-picture" class="">
</div>
<h6 class="">Choose Picture</h6>
</div>
</div>
<div class="register-body">
<p>Personal Information</p>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="user_id" id="user_id" class="form-control input-sm" placeholder="User ID" required>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="first_name" id="first_name" class="form-control input-sm" placeholder="First Name" style="text-transform: capitalize;" required>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="middle_name" id="middle_name" class="form-control input-sm" placeholder="Middle Name" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="last_name" id="last_name" class="form-control input-sm" placeholder="Last Name" style="text-transform: capitalize;" required>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="email" name="email" id="email" class="form-control input-sm" placeholder="Email Address" required>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="contact_no" id="contact_no" class="form-control input-sm" placeholder="Contact Number" required>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="password" name="password" id="password" class="form-control input-sm" placeholder="Password" required>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="password" name="password_confirmation" id="password_confirmation" class="form-control input-sm" placeholder="Confirm Password" required>
</div>
</div>
</div>
<label for="cvil_stat">Permanent address</label>
<div class="row">
<div class="col-sm-3 col-sm-3 col-md-3">
<label for="cvil_stat">Province</label>
<br>
<select class="form-group" name="province" id="province_id">
<option> ----- Select Option ----- </option>
<?php foreach($provinces as $province)
echo '<option value='.$province->province_id.'>'.$province->province_name.'</option>'?>
</select>
</div>
<div class="col-sm-3 col-sm-3 col-md-3">
<label for="gender">City</label>
<br>
<select class="form-group" name="city" id="city_id">
<option> ----- Select Option ----- </option>
</select>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<br>
<input type="text" name="street_name" id="street_name" class="form-control input-sm" placeholder="House no. / Street name" required>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="philhealth_no" id="philhealth_no" class="form-control input-sm" placeholder="Philhealth Number" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="pagibig_no" id="pagibig_no" class="form-control input-sm" placeholder="Pag-ibig Number" required>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="tin_no" id="tin_no" class="form-control input-sm" placeholder="TIN Number" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-sm-6 col-sm-6 col-md-6">
<input type="text" name="dependentnumber" id="dependentnumber" class="form-control input-sm" placeholder="Number of Dependent Child" style="text-transform: capitalize;" required>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="sss_no" id="sss_no" class="form-control input-sm" placeholder="SSS Number" required>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="place_ofb" id="place_ofb" class="form-control input-sm" placeholder="Place of Birth" style="text-transform: capitalize;" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-6 col-md-6">
<label for="gender">Birthday</label>
<br>
<select class="form-group" name="bday_month">
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<select class="form-group" name="bday_day">
<?php for($i=1;$i<32;$i++) { ?>
<option><?php echo $i ?></option>
<?php } ?>
</select>
<select class="form-group" name="bday_year">
<?php $y = date('Y'); ?>
<?php for($j=0;$j<120;$j++) { ?>
<option><?php echo $y-$j ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-6 col-sm-6 col-md-6">
<label for="gender">Religion</label>
<br>
<select class="form-group" name="religion">
<option> ----- Select Option ----- </option>
<?php foreach($religions as $religion)
echo '<option value='.$religion->religion_id.'>'.$religion->religion_name.'</option>'?>
</select>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-6 col-md-6">
<label for="cvil_stat">Civil Status</label>
<br>
<select class="form-group" name="civil_stat" id="civil_stat">
<option> ----- Select Option ----- </option>
<option value="Single">Single</option>
<option value="Married">Married</option>
<option value="Legally Separated">Legally Separated</option>
<option value="Widowed">Widowed</option>
</select>
</div>
<div class="col-sm-6 col-sm-6 col-md-6">
<label for="gender">Citizenship</label>
<br>
<select class="form-group" name="citizenship">
<option> ----- Select Option ----- </option>
<?php foreach($citizenships as $citizenship)
echo '<option value='.$citizenship->citizenship_id.'>'.$citizenship->citizenship_name.'</option>'?>
</select>
</div>
</div>
<p>Family Background</p>
<div class="row" id="field_div">
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="fathers_name" id="fathers_name" class="form-control input-sm" placeholder="Father's Name" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
<input type="text" name="fathers_occu" id="fathers_occu" class="form-control input-sm" placeholder="Occupation" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
<input type="text" name="fdate_birth" id="fdate_birth" class="form-control input-sm" placeholder="Date of birth" style="text-transform: capitalize;" required>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="mothers_name" id="mothers_name" class="form-control input-sm" placeholder="Mother's Name" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
<input type="text" name="mothers_occu" id="mothers_occu" class="form-control input-sm" placeholder="Occupation" style="text-transform: capitalize;" required>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
<input type="text" name="mdate_birth" id="mdate_birth" class="form-control input-sm" placeholder="Date of birth" style="text-transform: capitalize;" required>
</div>
</div>
</div>
<p>Educational Background</p>
<div class="control-btns">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3">
<button class="btn btn-primary btn-sm" onclick="add_field_educ(event);">+</button>
<button class="btn btn-danger btn-sm" onclick="remove_field_educ(event);">-</button>
</div>
</div>
</div>
<div id="wrapper_educ">
<div id="educ_div">
</div>
</div>
<p>Work Experience</p>
<div class="control-btns">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3">
<button class="btn btn-primary btn-sm" onclick="add_field_work(event);">+</button>
<button class="btn btn-danger btn-sm" onclick="remove_field_work(event);">-</button>
</div>
</div>
</div>
<div id="wrapper_work">
<div id="work_div">
</div>
</div>
<div class="register_footer">
<button type="submit" value="Register" class="btn btn-primary">Register</button>
<button class="btn btn-primary">Clear</button>
</div>
</div>
</div>
</form>
Here is my controller code that i want to print my submitted code:
public function reg_new() {
$this->form_validation->set_message('is_unique', 'The %s is already taken.');
$this->form_validation->set_error_delimiters('<div class="error"><li>','</li></div>');
if ($this->form_validation->run('reg_config') == FALSE) {
$this->index();
} else {
$register_data = array(
'User_Id' => $this->input->post('user_id'),
'First_Name' => $this->input->post('first_name'),
'Middle_Name' => $this->input->post('middle_name'),
'Last_Name' => $this->input->post('last_name'),
'Email' => $this->input->post('email'),
'Contact_no' => $this->input->post('contact_no'),
'Password' => $this->bcrypt->hash_password($this->input->post('password')),
'City_id' => $this->input->post('city'),
'Street' => $this->input->post('street_name'),
'Philhealth_num' => $this->input->post('philhealth_no'),
'Pagibig_num' => $this->input->post('pagibig_no'),
'Tin_num' => $this->input->post('tin_no'),
'Dependent_children' => $this->input->post('dependentnumber'),
'Sss_num' => $this->input->post('sss_no'),
'Place_of_birth' => $this->input->post('place_ofb'),
'Gender' => $this->input->post('gender'),
'Birthdate' => $this->input->post('bday_year') . "-" . date("m",strtotime($this->input->post('bday_month'))) . "-" . $this->input->post('bday_day'),
'Religion' => $this->input->post('religion'),
'Citizenship' => $this->input->post('citizenship'),
'Civil_status' => $this->input->post('civil_stat'),
'fathers_name' => $this->input->post('fathers_name'),
'fathers_occupation' => $this->input->post('fathers_occu'),
'father_bdate' => $this->input->post('fdate_birth'),
'mothers_name' => $this->input->post('mothers_name'),
'mothers_occupation' => $this->input->post('mothers_occu'),
'mother_bdate' => $this->input->post('mdate_birth'),
'User_Status' => $this->user_stat,
'Delete_Status' => 0,
'Position_Id' => 0,
);
if($this->input->post('civil_stat') == 'Married') {
$spouse_data = array (
'Spouse_name' => $this->input->post('spouse_name'),
'Spouse_occupation' => $this->input->post('spouse_occu'),
'Spouse_bdate' => $this->input->post('spouse_dateofb'),
);
}
foreach ($this->input->post('educ_opt') as $educ) {
$count_educ = $count_educ++;
}
print_r($register_data);
print_r($count_educ);
print_r($spouse_data);
}
}
please take a look with my code why i cant submit it from controller.
thanks.
Thanks guys.. i just figured it out, its because of my form validation that i thought it doesn't submit because it did not satisfy my form validation and for that i returned $this->index();

Cannot insert when clicking a button in Mysql using PHP

I am a beginner in web development, I used have an html elements, like textbox and other type of elements, I want to use them as my object and when they have a value and click a button, it will save the value of all the elements in mysql.
I have a code like this, but it cannot be inserted and anything does not happen when clicking a button.
Please help.
PHP:
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'ytp');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
if(!$db ) {
die('Could not connect: ' . mysqli_error());
}
$fname = "";
$mname = "";
$lname = "";
$funame = "";
$cnum = "";
$bday = "";
$age = "";
$add = "";
if (isset($_POST['submit'])){
$fname = $_POST['fName'];
$mname = $_POST['mName'];
$lname = $_POST['lName'];
$funame = $_POST['fuName'];
$cnum = $_POST['Cnumber'];
$bday = $_POST['bday'];
$age = $_POST['age'];
$add = $_POST["address"];
}
$sql = "INSERT INTO employee ".
"(fName,mName,lName,fuName,cNumber,bDay,Age,Address) ".
"VALUES ('$fname','$mname','$lname','$funame','$cnum','$bday','$age','$add' )";
if (! mysqli_query($db , $sql)){
echo 'Cannot Insert';
}
else{
echo 'Success';
}
?>
HTML:
<div class="content">
<div class="row">
<div class="col-md-10">
<div class="card">
<div class="card-header">
<h5 class="title">Add User Information</h5>
</div>
<div class="card-body">
<form method="POST" action="php_functions\saveEmployee.php" name="INSERT">
<div class="row">
<div class="col-md-5 pr-md-1">
<div class="form-group">
<label>Company (disabled)</label>
<input type="text" class="form-control" disabled="" placeholder="Company" value="Benchmark Valuer's Inc.">
</div>
</div>
<div class="col-md-3 px-md-1">
<div class="form-group">
<label>ID</label>
<input type="text" class="form-control" placeholder="User ID" value="" id="id" name ="id" disabled>
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" placeholder="s.sample#gmail.com" id="email" name ="email">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 pr-md-1">
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" placeholder="First Name" id="fName" name ="fName">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Middle Name</label>
<input type="text" class="form-control" placeholder="Middle Name" id="mName" name ="mName">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" placeholder="Last Name" id="lName" name ="lName">
</div>
</div>
<div class="col-md-4 pl-md-1" hidden>
<div class="form-group">
<label>Fullname</label>
<input type="text" class="form-control" placeholder="Full Name" id="fuName" name ="fuName">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 pr-md-1">
<div class="form-group">
<label>Contact Number</label>
<input type="tel" class="form-control" placeholder="Contact Number" id="Cnumber" name="Cnumber">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Age</label>
<input type="number" class="form-control" placeholder="Age" id="age" name="age">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Birthday</label>
<input type="date" class="form-control" placeholder="Birthday" id="bday" name="bday">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Address</label>
<input type="text" class="form-control" placeholder="Home Address" id="address" name ="address">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 pr-md-1">
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" placeholder="Username" id="uName">
</div>
</div>
<div class="col-md-4 px-md-1">
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password" id="pWord">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>UserType</label>
<input type="number" class="form-control" placeholder="0" id="uType">
</div>
</div>
</div>
<div class="row" hidden>
<div class="col-md-12">
<div class="form-group">
<label>Image Path:</label>
<input type="text" class="form-control" placeholder="C:\\" id="imageURL">
</div>
</div>
</div>
</form>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-fill btn-primary" id="submit" name="submit">Save</button>
<button class="btn btn-fill btn-success" id="btnBrowse">Browse</button>
<button class="btn btn-fill btn-danger" id="btnCancel">Cancel</button>
</div>
</div>
</div>
</div>
</div>
Your HTML form is closing before submit button. You should close that after submit button and also need to manage hierarchy of opening form tag as below:
<form method="POST" action="php_functions\saveEmployee.php" name="INSERT">
<div class="card-body">
<div class="row">
<div class="col-md-5 pr-md-1">
<div class="form-group">
<label>Company (disabled)</label>
<input type="text" class="form-control" disabled="" placeholder="Company" value="Benchmark Valuer's Inc.">
</div>
</div>
<div class="col-md-3 px-md-1">
<div class="form-group">
<label>ID</label>
<input type="text" class="form-control" placeholder="User ID" value="" id="id" name ="id" disabled>
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" placeholder="s.sample#gmail.com" id="email" name ="email">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 pr-md-1">
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" placeholder="First Name" id="fName" name ="fName">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Middle Name</label>
<input type="text" class="form-control" placeholder="Middle Name" id="mName" name ="mName">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" placeholder="Last Name" id="lName" name ="lName">
</div>
</div>
<div class="col-md-4 pl-md-1" hidden>
<div class="form-group">
<label>Fullname</label>
<input type="text" class="form-control" placeholder="Full Name" id="fuName" name ="fuName">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 pr-md-1">
<div class="form-group">
<label>Contact Number</label>
<input type="tel" class="form-control" placeholder="Contact Number" id="Cnumber" name="Cnumber">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Age</label>
<input type="number" class="form-control" placeholder="Age" id="age" name="age">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>Birthday</label>
<input type="date" class="form-control" placeholder="Birthday" id="bday" name="bday">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Address</label>
<input type="text" class="form-control" placeholder="Home Address" id="address" name ="address">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 pr-md-1">
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" placeholder="Username" id="uName">
</div>
</div>
<div class="col-md-4 px-md-1">
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password" id="pWord">
</div>
</div>
<div class="col-md-4 pl-md-1">
<div class="form-group">
<label>UserType</label>
<input type="number" class="form-control" placeholder="0" id="uType">
</div>
</div>
</div>
<div class="row" hidden>
<div class="col-md-12">
<div class="form-group">
<label>Image Path:</label>
<input type="text" class="form-control" placeholder="C:\\" id="imageURL">
</div>
</div>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-fill btn-primary" id="submit" name="submit">Save</button>
<button class="btn btn-fill btn-success" id="btnBrowse">Browse</button>
<button class="btn btn-fill btn-danger" id="btnCancel">Cancel</button>
</div>
</form>
Hope it helps you.
the form has been closed before the submit button.
the </form> tag should be placed after the <div class="card-footer">...</div>.
please try it. hope it will help.

Not displaying the error messages in PHP

If there are any errors while registration or login into the sit then it is not displaying the error message just printing the variable.Here is the code.Tried by doing echo as well but it is also not working.Tried with storing the result in a variable and displaying the message but still not worked.
<?php
include 'includes/db.php';
$match = '';
if(isset($_POST['submit_user']))
{
$email = $_POST['email'];
$check=mysqli_query($conn,"select * from users where user_email='$email'");
$checkrows=mysqli_num_rows($check);
if($checkrows>0)
{
$msg = "Email Already Exists";
header('Location:registration.php?msg=$msg');
}
else
{
if($_POST['password'] == $_POST['con_password'])
{
$ins_sql = "INSERT INTO users (first_name, last_name, user_email, user_password, username) VALUES ('$_POST[first_name]', '$_POST[last_name]', '$_POST[email]', '$_POST[password]', '$_POST[username]')";
$run_sql = mysqli_query($conn,$ins_sql);
}
else
{
$match = '<div class="alert alert-danger">Password doesn&apos;t match!</div>';
}
}
}
?>
<form class="form-horizontal" action="registration.php" method="post" role="form">
<div class="body">
<div class="row clearfix">
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="First Name" name="first_name" id="first_name" onkeypress="return checkSpcialChar(event)" required>
</div>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="Last Name" name="last_name" id="last_name" required>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="Enter Your Email" name="email" id="email" required>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="password" class="form-control" placeholder="Password" name="password" id="password" required>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="type" class="form-control" placeholder="Confirm Password" name="con_password" id="con_password" required>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="Enter Username" name="username" id="username">
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group drop-custum">
<select class="form-control show-tick" name="user_role" id="user_role" required>
<option value="">-- Select User role --</option>
<option value="admin">Admin</option>
<option value="employee">Employee</option>
</select>
</div>
</div>
<div class="col-sm-12">
<button type="submit" class="btn btn-raised g-bg-cyan" name="submit_user" id="subject">Submit</button>
<button type="submit" class="btn btn-raised">Cancel</button>
</div>
<span>
<?php if(isset($_GET['msg']))
echo $_GET['msg'];
?>
</span>
</div>
</div>
</form>

The temporary folder is missing in codeigniter

I am using Codeigniter 3
and uploading a file using upload library in CodeIgniter whenever I upload the file it's giving me The temporary folder is missing.
I am confusing why it's giving me this error because I uploaded my project on a server its working fine on that server but when I upload same files on another server it's giving me this error I don't why.
Here is my code
HTML
<div class="storecreatewrapper">
<div class="toptext">
<div class="container">
<div class="row">
<div class="col-md-12">
<p>Let's build your store at <span><?php echo PROJECT;?>!</span></p>
</div>
</div>
</div>
</div>
<div class="formwrapper">
<form action="<?php echo site_url('shop/addshop')?>" enctype="multipart/form-data" method="post" accept-charset="utf-8" id="adsp_09">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="mianstoreform">
<div class="row">
<div class="col-md-12">
<div class="formtopimg">
<img src="<?php echo base_url('assets/images/logos/storepic.png') ?>" >
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Basic Shop Information</p>
</div>
</div>
<div class="form-group">
<?php c_error();?>
</div>
</div>
</div>
<div class="stformfields">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Shop Name <span class="red">*</span></label>
<?php
$shopname = array(
'class' => 'form-control',
'id' => 'shopname',
'placeholder' => 'Shop Name',
'name'=>'shopname'
);
echo form_input($shopname);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Shop URL <span class="red">*</span></label>
<?php
$shopurl = array(
'class' => 'form-control',
'id' => 'fohopurl',
'name'=>'shpurl',
'placeholder' => 'Shop URL: www.'.PROJECT.'.com/shops/URL'
);
echo form_input($shopurl);
?>
</div>
</div>
</div>
</div>
<div class="custmhr"></div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Account Verification Detail</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="frmrads">
<div class="pull-left cusradhead">
Account Type:
</div>
<div class="pull-left">
<div class="radio">
<label>
<input class="act_9" type="radio" name="at" id="individual" value="individual" checked>
Individual Professional.
</label>
</div>
<div class="radio">
<label>
<input class="act_9" type="radio" name="at" id="business" value="business">
Business (Selling On Behalf of a Business Entity).
</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="documtslt">
<div class="row">
<div class="col-sm-10 lftcolset">
<div class="form-group">
<select name="dcname" id="dcm_67">
<option selected="select">
Document (Please Select)
</option>
<option value="national id">National ID</option>
<option value="passport">Passport</option>
</select>
</div>
</div>
<div class="col-sm-2 rytcolset">
<input id="file-upload" type="file" name="ushplg" style="display:none"/>
<button type="button" id="upfile1" class="btn cutsltbtn" for="file-upload">Image</button>
</div>
</div>
</div>
</div>
</div>
<div class="docfrmffl">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<?php
$shopurl = array(
'class' => 'form-control',
'id' => 'document_id',
'placeholder' => 'Document ID',
'name'=>'document_id'
);
echo form_input($shopurl);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="notetxt">
Note: English (a-z,A-Z), digits(0-9), - , spaces.
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<?php
$shopurl = array(
'class' => 'form-control expiry_date',
'id' => 'datepicker',
'placeholder' => 'Expiry Date',
'name'=>'expiry_date'
);
echo form_input($shopurl);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="notetxt">
Note: JPEG, PNG or PDF only and 2MB file size.
</p>
</div>
</div>
</div>
<div class="custmhr"></div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Order Pickup Location</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="frmrads">
<div class="pull-left">
<?php if(is_logedin()): //if logedin ?>
<?php if(
$this->session->userdata('city_id') && $this->session->userdata('area_id') && $this->session->userdata('direction')
):
?>
<div class="radio">
<label>
<input class="loc_09" type="radio" name="location" id="shipping" value="shipping" checked>
Same as my shipping address
</label>
</div>
<?php else: // if loggedin and city area and direction not found. ?>
<div class="radio">
<label>
<input class="loc_09" type="radio" name="location" id="new_address" value="new_address" checked>
Register a new address
</label>
</div>
<?php endif; //checking if shipping addres set or not..?>
<?php else: ?>
<div class="radio">
<label>
<input class="loc_09" type="radio" name="location" id="new_address" value="new_address" checked>
Register a new address
</label>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="locations">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>City <span class="red">*</span></label>
<select name="city" class="city_9 sada" disabled>
<option value="none" selected="select">City</option>
<?php if($cities->num_rows() > 0):
foreach ($cities->result() as $city):
?>
<option value="<?php echo $city->c_id ?>">
<?php echo $city->city_name ?></option>
<?php endforeach;?>
<?php endif; ?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Area <span class="red">*</span></label>
<!-- <select name="area" id="area" class="sada" disabled>
<option selected="select">Select Area</option>
</select> -->
<span class="pslare">
</span>
<input type="text" class="form-control caresshx" id="areasped" placeholder="Area" value="">
<input type="hidden" name="area" value="" id="ardix">
<!-- <select name="area" id="area" class="sada" <?php if($shop_info[0]['location'] == 1){ echo 'disabled';}?>>
<option selected="select">Select Area</option>
</select> -->
<ul class="ullist list-unstyled">
</ul>
</div>
</div>
</div>
</div>
<div class="docfrmffl">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" class="form-control sada" name="street" id="street" placeholder="Street" disabled>
</div>
<div class="form-group">
<input type="text" name="build_num" class="form-control sada" placeholder="Building Name" disabled id="build_num">
</div>
<div class="form-group">
<?php
$rft = array(
'class'=>'form-control',
'name'=>'rft',
'placeholder'=>'House Number'
);
echo form_input($rft);
?>
</div>
<div class="form-group">
<label>Direction <span class="red">*</span></label>
<textarea class="form-control" name="direction" rows="3" id="flladdrs" placeholder="Direction"></textarea>
</div>
<div class="form-group">
Click here to choose from map
</div>
<div class="form-group tsslid" id="opmap" style="display: none">
<div class="form-group">
<input id="address" type="text" placeholder="Enter an address" class="form-control">
<!-- Cancel -->
</div>
<div class="form-group">
Close map
</div>
<div id="map"></div>
</div>
</div>
</div>
</div>
<div class="custmhr"></div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Contact Information</p>
</div>
</div>
</div>
</div>
<div class="docfrmffl">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>First Name <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" class="form-control" name="fname" placeholder="First Name" value="<?php echo get_session_element('fname');?>" readonly id="fname">
<?php else: ?>
<input type="text" class="form-control" name="fname" placeholder="First Name" id="fname">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Last Name <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="lname" class="form-control" placeholder="Last Name" value="<?php echo get_session_element('lname');?>" readonly id="lname">
<?php else: ?>
<input type="text" name="lname" class="form-control" placeholder="Last Name" id="lname">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Email <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="email" class="form-control" placeholder="Email" value="<?php echo get_session_element('email');?>" readonly id="email">
<?php else: ?>
<input type="text" name="email" class="form-control" placeholder="Email" id="email">
<?php endif; ?>
</div>
</div>
</div>
<?php if(!is_logedin()): ?>
<div class="row" class="lng" id="lng">
<div class="col-md-12">
<div class="form-group">
<label>Password <span class="red">*</span></label>
<input type="password" name="pass" id="pass" placeholder="Enter You Password" class="form-control" >
</div>
<div class="form-group">
<label>Confirm Password <span class="red">*</span></label>
<input type="password" id="cnpass" placeholder="Confirm Password" class="form-control" name="cnpass">
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Mobile Phone <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="mob" class="form-control" placeholder="Mobile Phone" value="<?php echo get_session_element('mobile');?>" id="mob">
<?php else: ?>
<input type="text" name="mob" class="form-control" placeholder="Mobile Phone" id="mob">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>LandLine <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="landline" class="form-control" placeholder="LandLine" value="<?php echo get_session_element('phone');?>" id="landline">
<?php else: ?>
<input type="text" name="landline" class="form-control" placeholder="LandLine" id="landline">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="agreementtxt">
<input type="checkbox" name="agreement" id="arg_098">
I have read and accepted terms and conditions of the agreement.
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="createbtndv">
<input type="submit" class="btn custmsubmit edupfl" value="Create Store" disabled="disabled" id="btnsb">
</div>
<div class="form-group snofd">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
echo form_close();
?>
</div>
</div>
PHP
$image_path = realpath(APPPATH . '../assets/images/usershop');
$config['upload_path'] = $image_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = random_string('alnum', 16);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('ushplg'))
{
$error = $this->upload->display_errors('<p>','</p>');
c_flash('alert-danger',$error,'shop/open');
}
else
{
$filename = $this->upload->data();
$data['doc_image'] = $filename['file_name'];
}
$add_n_shop = $this->mod_shop->add_new_shop($data);
if ($add_n_shop)
{
c_flash('alert-success','Your shop has been created but review by admin.','user/about');
}
else
{
c_flash('alert-danger','Your shop has not been created.','shop/open');
}
This can also happen when you run out of disk space or there don't have available inodes. In my case I faced this error because PHP session files were using up all the inodes.
The following answer can help you with further investigation:
https://askubuntu.com/a/1107896

Calling controllers different methods from view page using codeigniter

I am working on codeigniter project in which viwe page having textboxes, radio buttons and button.I fetched textbox values from database and manually enter from date and to date then by clicking on save button insert query gets empty values because in controller i called all functions serially in index function.What is the best solution to call controller methods on each event of view page?
leave_appl_view.php
<form action="leave_apply_control/index" method="post" id="myForm">
<div class="row">
<div class="col-md-3">
<div class="form-group label-floating">
<label class="control-label">Emp ID</label>
<?php if(!empty($emp_leave))
{
foreach ($emp_leave as $liv)
{ ?>
<input type="text" class="form-control" name="id" value="<?php echo $liv->employee_id ?>" >
</div>
</div>
<div class="col-md-4">
<div class="form-group label-floating">
<label class="control-label">Employee Name</label>
<input type="text" class="form-control" name="empname" id="empname" value="<?php echo $liv->employee_name ?>" >
</div>
</div>
<div class="col-md-4">
<div class="form-group label-floating">
<label class="control-label">Email address</label>
<input type="email" class="form-control" name="empmail" id="empmail" value="<?php echo $liv->email ?>" >
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group label-floating">
<label class="control-label">Leave type: </label>
<input type="radio" id="half" name="type" onclick="Checkradiobutton()" value="half"> Half Day
<input type="radio" id="full" name="type" onclick="Checkbutton()" value="full" Checked> Full Day
</div>
</div>
<div class="col-md-3">
<div class="form-group label-floating" id="frm_dt">
<label class="control-label">From Date: </label>
<input type="text" class="form-control" id="datepicker1" name="from" ></p>
</div>
</div>
<div class="col-md-3">
<div class="form-group label-floating" id="to_dt">
<label class="control-label">To Date: </label>
<input type="text" class="form-control" id="datepicker2" name="to" ></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group label-floating">
<label class="control-label">Balance Leaves</label>
<input type="text" class="form-control" name="bal_leave" value="<?php echo $liv->balanced_leaves ?>" >
</div>
<?php }
}
?>
</div>
<div class="col-md-3">
<div class="form-group label-floating">
<label class="control-label">Applied Leaves</label>
<input type="text" class="form-control" name="totaldays" id="totaldays" readonly>
</div>
</div>
<div class="col-md-3">
<div class="form-group label-floating">
<label class="control-label">Applied Date</label>
<input type="text" class="form-control" name="todayDate" id="todayDate" value="<?php echo date("d/m/Y"); ?>" readonly>
</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="form-group label-floating">
<label class="control-label">Reason </label>
<TEXTAREA class="form-control" id="reason" name="reason"> </TEXTAREA>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary" id="submit" name="submit" onclick="<?php // echo base_url() ?>leave_apply_control/save_data">Apply</button>
<button type="reset" class="btn btn-primary" onclick="<?php echo base_url();?>leave_apply_control" >Reset</button>
</form>
leave_Apply_control.php
<?php
class leave_apply_control extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('form','url'));
$this->load->library(array('session', 'form_validation'));
$this->load->library('calendar');
$this->load->database();
$this->load->model('user_model');
$this->load->helper('date');
}//contruct close
function index()
{
$id=$this->session->userdata('id');
$data['foren_id'] = $this -> user_model -> get_emp_id($id);
foreach($data['foren_id'] as $fk)
{
//echo "////control page fk is ".$fk->emp_id;
}
$data2['emp_leave'] = $this->user_model->get_leave_count($fk->emp_id);
$this->load->view('leave_application',$data2);
$this->save_data();
}
public function save_data()
{
$fd = date('Y-m-d',strtotime($this->input->post('from')));
$td = date('Y-m-d',strtotime($this->input->post('to')));
$data = array(
'employee_id' => $this->input->post('id'),
'emp_name' => $this->input->post('empname'),
'leave_from' => $fd,
'leave_to' => $td,
'no_of_days' => $this->input->post('totaldays'),
'applied_date' => date('Y-m-d H:i:s'),
'reason' => $this->input->post('reason'),
'mail' => $this->input->post('empmail'),
'leave_type' => $this->input->post('type'),
'balance_leaves' => $this->input->post('bal_leave'),
'status' => 1,
);
$this->user_model->insert_leave($data);
}
}

Categories