class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model("User_model");
$this->load->helper("form");
$this->load->helper("url");
}
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
function do_upload($name){
$this->load->helper("form");
$config['upload_path'] = 'upload/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '102400';
$config['max_height'] = '76800';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload($name)) {
}else{
$databasea['upload_data'] = $this->upload->data();
$this->load->library('image_lib');
return $databasea['upload_data']['file_name'];
}
}
public function index()
{
if(isset($_POST['resgisterd'])){
$insert['fname'] = $_POST['fname'];
$insert['lname'] = $_POST['lname'];
$insert['address'] = $_POST['address'];
$insert['country'] = $_POST['country'];
$insert['state'] = $_POST['state'];
$insert['city'] = $_POST['city'];
$insert['tittle'] = $_POST['tittle'];
$insert['company'] = $_POST['company'];
$insert['phone'] = $_POST['phone'];
$insert['email'] = $_POST['email'];
$insert['password'] = $_POST['password'];
$insert['image'] = $this->do_upload('image');
$this->User_model->insertrow($insert,'candidate');
}
$data['country'] = $this->User_model->fetchrow('country');
$this->load->view('front/reg',$data);
}
function getstate($id){
$whr['country_id'] = $id;
$state = $this->User_model->fetchrowedit('state',$whr);
$option = '';
foreach ($state as $states ) {
$option = '<option>Select State</option>';
$option .= '<option value="'.$states->state_id.'">'.$states->state_name.'</option>';
}
print_r($option);
}
function getcity($sid){
$whr['state_id'] = $sid;
$city12 = $this->User_model->fetchrowedit('city',$whr);
echo $this->db->last_query();
foreach ($city12 as $city123 ) {
$option1 = '';
$option1 .= '<option value="'.$city123->city_id.'">'.$city123->city_name.'</option>';
}
print_r($option1);
}
function checkremote(){
$uName['email'] = $this->input->post('email');
$isUNameCount = $this->User_model->alreadyexits('candidate',$uName);
if($isUNameCount > 0){
echo 'false';
}else{
echo 'true';
}
}
function login(){
if(isset($_POST['login'])){
$log['email'] = $_POST['email'];
$log['password'] = $_POST['password'];
$details = $this->User_model->fetchrowlogin($log,'candidate');
if(count($details)){
$ids = $details['id'];
$email = $details['email'];
$fname = $details['fname'];
$this->session->set_userdata(array(
'custid' => $ids,
'emailid'=> $email,
'fname'=> $fname,
));
redirect('http://localhost/test27/index.php/welcome/dashboard');
}else{
redirect(base_url().'front1');
}
}
$this->load->view('front/login');
}
function dashboard(){
$id = $this->session->userdata('custid');
$whr['id']=$id;
if(isset($_POST['resgisterd'])){
$insert['fname'] = $_POST['fname'];
$insert['lname'] = $_POST['lname'];
$insert['address'] = $_POST['address'];
$insert['country'] = $_POST['country'];
$insert['state'] = $_POST['state'];
$insert['city'] = $_POST['city'];
$insert['tittle'] = $_POST['tittle'];
$insert['company'] = $_POST['company'];
$insert['phone'] = $_POST['phone'];
if(!empty($_FILES['image']['name'] && isset($_FILES['image']['name']))){
$insert['image'] = $this->do_upload('image');
}else{
$insert['image'] = $_POST['preimage'];
}
$whrs['id']=$id;
$this->User_model->updaterow($insert,'candidate',$whrs);
echo $this->db->last_query();
redirect('http://localhost/test27/index.php/welcome/dashboard');
}
$data['info'] = $this->User_model->fetchrowedit('candidate',$whr);
$data['country'] = $this->User_model->fetchrow('country');
$this->load->view('front/dashboard',$data);
}
function message_box(){
$id = $this->session->userdata('custid');
$data['message_info']= $this->User_model->messages_list($id);
$this->load->view('front/message_box',$data);
}
function perticular($id){
$id1 = $this->session->userdata('custid');
$data['message_info']= $this->User_model->messages_perticular($id,$id1);
echo $this->db->last_query();
$this->load->view('front/message_box',$data);
}
function login(){
if(isset($_POST['login'])){
$login['email'] = $_POST['email'];
$login['password'] = $_POST['password'];
$
}
}
function logout(){
$this->session->unset_userdata('custid');
$this->session->unset_userdata('emailid');
$this->session->unset_userdata('fname');
}
}