codeigniter

Database driven routing in CodeIgniter 2.x

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-10 11:48:40
问题 I am creating a site that will have a lot of routes that will need to be added to the routes file (800+) - obviously I do not want to manually add these one by one into the routes config file. Can anyone suggest the best practice to have my routes loaded automatically from the database. Is there a suitable library/helper that will perform this task that works with version 2.x For instance.. $route['apple'] = 'brands/index'; $route['blackberry'] = 'brands/index'; $route['htc'] = 'brands/index'

How to set Dynamic base url to https in CodeIgniter?

谁都会走 提交于 2020-01-10 10:53:09
问题 I try the use a dynamic base url in this post: Set Dynamic Base Url in CodeIgniter But I used to be use the http, but now, I would like to change to https, how can I do so? Thanks. 回答1: In your config/config.php, try this: $root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; $root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['base_url'] = $root; 回答2: You can use codeigniter hooks in pre_controller you just change the base

How to set Dynamic base url to https in CodeIgniter?

混江龙づ霸主 提交于 2020-01-10 10:52:30
问题 I try the use a dynamic base url in this post: Set Dynamic Base Url in CodeIgniter But I used to be use the http, but now, I would like to change to https, how can I do so? Thanks. 回答1: In your config/config.php, try this: $root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; $root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['base_url'] = $root; 回答2: You can use codeigniter hooks in pre_controller you just change the base

CodeIgniter - Checking to see if a value already exists in the database

时光怂恿深爱的人放手 提交于 2020-01-10 07:50:31
问题 Im running CodeIgniter for a project of mine ... Im fairly new to this, i have the standard form validation checks for my form, except im unsure of how to check if the value already exists in the database. This is what i have for my form validation rules so far $this->form_validation->set_rules('rolename', 'Role Name', 'trim|required|xss_clean'); $this->form_validation->set_rules('rolekey', 'Role Key', 'trim|required|xss_clean'); The 'rolekey' is what i need to check against the 'rolekey'

Change url in php after reloading a page

大城市里の小女人 提交于 2020-01-10 06:08:27
问题 My home page url looks like this http://localhost/mediabox/home/box/12 I have a link of language on home page when a user clicks on that link i am sending that language id as query string , the page reloads and the url converts to http://localhost/mediabox/home/box/?bid=12&ln=2 I want to reload the page with the new language but don't want to change my url i-e I want my URL to be http://localhost/mediabox/home/box/12 after the page loads How it is possible please me some gud ideas Thanks 回答1:

pagination not working in codeigniter

旧城冷巷雨未停 提交于 2020-01-10 05:42:11
问题 my controller page public function index() { $data['error']=""; $data['h']=""; $this->load->library('pagination'); $config['base_url'] = base_url().'Imagec/index'; $config['total_rows'] = 10; $config['per_page'] = 2; $config["uri_segment"] = 4; $this->pagination->initialize($config); $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0; $data['h']=$this->Inserts_model->select($config["per_page"], $page); $data["links"] = $this->pagination->create_links(); $this->load->view('select

Codeigniter 2 - Callback function in My_Controller

北慕城南 提交于 2020-01-10 05:42:06
问题 I have all my callback functions in My_Controller so that they are not repeated throughout the website. This works fine but for some reason one of my functions is not working when I am posting information using AJAX but is working on other pages. The message I get back when I use the callback is: Unable to access an error message corresponding to your field name. But then I've created a message for it using set_message() and it works fine on the other page without AJAX. If you were interested

How to paginate with codeigniter 3.0.1

三世轮回 提交于 2020-01-10 05:36:27
问题 I am trying to create pagination using CodeIgniter. It displays links fine, but when I click the links it shows 404 error. How to solve this? Controller Example.php class example extends CI_controller { public function __construct() { parent::__construct(); $this->load->model('Donor_model'); $this->load->library('pagination'); $this->load->helper('url'); $this->load->library('form_validation'); } public function get_details() { $config['base_url'] = base_url('info'); $config['total_rows'] =

Why the Codeigniter session does not expire after closing the browser?

喜你入骨 提交于 2020-01-10 04:09:13
问题 Problem scenario If a user A logs into the application then the user id set in session. After doing some tasks user A closes his browser and leaves the computer. Short time later, user B came and open browser and see the application was in logged in state. User B can also open an internal url, which directly redirects him into the application without any authentication by using the previous session. My Configuration $config['sess_cookie_name'] = 'cisession'; $config['sess_expiration'] = 7200;

Merge multiple PDF files into one in PHP [closed]

风格不统一 提交于 2020-01-10 03:25:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I would like to merge multiple PDF files to one. The PDF files are on different sites so they should first be downloaded and merged to one. We work with PHP and Codeigniter. Does somebody know an solution for my problem? 回答1: yes. i have merged pdf's. Get the fpdf and fpdi libraries and put them in to the code