codeigniter

CodeIgniter authenticate the user in every Controller

我是研究僧i 提交于 2020-01-25 10:39:06
问题 I'm building my first project in Codeigniter, using Tank_auth to handle my CMS authentication. It's working ok but I have a question about best practices. Currently, every function in every controller has the following structure: public function add() { if ($this->tank_auth->is_logged_in()) { $data['stuff'] = 'stuff'; $this->load->view('admin/cms_add',$data); } else { redirect('/admin/login/'); } } With quite a few controllers, and a few functions in each, it's starting to get repetitive, and

missing token ‘access-control-allow-origin’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel - react js

安稳与你 提交于 2020-01-25 10:19:05
问题 My reactjs application works with api. My api is written in php language and CodeIgniter framework. https://github.com/chriskacerguis/codeigniter-restserver this is my api: `<?php defined('BASEPATH') OR exit('No direct script access allowed'); require APPPATH . '/libraries/REST_Controller.php'; class Api extends REST_Controller { public function __construct($config = 'rest') { parent::__construct($config); $this->load->model('m_user'); $this->load->model('m_cart'); header('Access-Control

Not working shared hosting cPanel cronjob under Codeigniter

前提是你 提交于 2020-01-25 10:13:40
问题 Despite there are many posts with a similar topic, I couldn't find anyone matching my case that I briefly describe here. This is the testing script <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require 'DashboardBase.php'; class Hello extends CI_Controller { public function message($to = 'World') { echo "Hello {$to}!".PHP_EOL; print "Hello {$to}!".PHP_EOL; log_message('error',"Hello {$to}!".PHP_EOL); } } ?> The web server is under a shared hosting; it is used cPanel

changing url displayed to user in codeigniter

别来无恙 提交于 2020-01-25 08:13:28
问题 I don't know if this is strange request or not, but I have a page with users profiles displaying. Each user has unique username of course and those are included in links to associated with their names. when clicked it goes to their profile: profile/profile_guest/username When the user clicks on one of the profiles, it goes to user's profile and url in the address bar is: http://domain.com/profile/profile_guest/ahlam What I want to achieve is to configure routes.php to handle this. so once

is it possible to post two datas in one column in mysql database? [closed]

懵懂的女人 提交于 2020-01-25 06:59:50
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 months ago . What I want to do is I want to post two datas in one table but I don't know if it's possible or not. Is there any way that a column can hadle two datas or more at once? Here is the modal Like for example I have two monitors that I want for my unit. But from what I can see from

How to loop a data in php [duplicate]

人走茶凉 提交于 2020-01-25 06:51:33
问题 This question already has an answer here : Loop results based on category but only show category once (1 answer) Closed 2 months ago . I want to loop my data Like this Like this Not like this My Controller: function bills($patient_id){ $data['payments'] = $this->model_patient->getpayments($patient_id); $this->load->view('includes/header'); $this->load->view('billing', $data); $this->load->view('includes/footer'); } My Model: // joining my 3 tables, i want to display the procedures made by

Can we use two database in same view in Codeigniter?

独自空忆成欢 提交于 2020-01-25 06:23:02
问题 I want to access data from two different database. I want to print the records from two database into same view. Now my first query is from the another database then the second query is from default database. So I get an error that SecondDatabase.tablenmae doesn't exist and actually the table is in default database So I defined them like this: $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'root'; $db['default'][

Can we use two database in same view in Codeigniter?

故事扮演 提交于 2020-01-25 06:22:58
问题 I want to access data from two different database. I want to print the records from two database into same view. Now my first query is from the another database then the second query is from default database. So I get an error that SecondDatabase.tablenmae doesn't exist and actually the table is in default database So I defined them like this: $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'root'; $db['default'][

codeigniter timespan function

被刻印的时光 ゝ 提交于 2020-01-25 02:54:27
问题 Hello i have now search the hole web and found a lot but i just dont know how to make it to work so now im asking here for help i want to do so then a person create a comment it should said "created 1 sec. ago" and then 1 min and 1 hour and like that :) can some one help me with that ? thanks 回答1: This is basically human readable format, and can be completed by mathematical checks to check the distance of times, working snippet below: function RelativeTime($timestamp) { $difference = time() -

Redirecting to mobile subdomain in a CI application

浪尽此生 提交于 2020-01-25 01:23:04
问题 I have a web app of which I would like to create a mobile version with jQuery Mobile. The existing application is built in CodeIgniter; I'll be using the same controllers, models where I can; (especially models since I'll be needing the same data anyway, might have to write new controllers). I'm a bit confused as to how to get started. I want to put my mobile version on a subdomain ( m.myhost.tld ), however.. since my app is at www.myhost.tld and I don't feel like copying it all over to