codeigniter

Codeigniter Validation Rules Help

I want to validate landphone and mobile phone fields in my CI application. I have set validation rules as integer but user cannot enter values seperated by " - " . If i use "text" type, user can enter alphabets also.....how do i solve this issue....i want user to enter "-" and "+" values in the fields and not any other texts Code: $th...

Using slugs in codeigniter

I have heard of people using slugs for generating clean urls. I have no idea how it works. Currently i have a codeigniter site which generates url's like this www.site.com/index.php/blog/view/7 From what i understand by maintaining a slug field it is possible to achieve urls like www.site.com/index.php/blog/view/once-upon-a-time Ho...

Form Validation w/ sql + codeigniter

Hi, I'm working on creating a callback function in codeigniter to see if a certain record exists in the database, and if it does it'd like it to return a failure. In the controller the relevent code is: function firstname_check($str) { if($this->home_model->find_username($str)) return false; true; } Then in the model I check th...

codeigniter html output (for forms in this case)

Hey, I was wondering, is there any easy way to have the html generated by codeigniter be more structured and more readable? For example, if I do this: echo form_open('do/send',array("id" => "contact_form")); echo form_label("Name:", "name"); echo form_input(array("name" => "name")); echo form_submit("submit", "Submit"); echo form...

Code Igniter Redirect Issues with GET parameters

I am having difficulty with code igniter routing. http://www.mysite.com goes to the right controller and does the right thing. However, http://www.mysite.com/?ref=p&t2=455 causes a 404 error. Also http://www.mysite.com/mycontroller/mymethod/?ref=p&t2=455 works fine. I changed the uri_protocol in the config.php file and tried...

Autoload Config for Pagination in CodeIgniter not working

Hello all I am trying to implement pagination in my CI webapp. Now I put the config for pagination inside a config file like this... <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $config['base_url'] = "http://example.com/index.php/home/index"; $config['num_links'] = "9"; $config['per_page'] = "20"; $config...

How do I catch strings that don't start with "ajax/" using regex for CodeIgniter?

I'm working on some routes for my CodeIgniter application, and I need to declare a 'catch-all'/except one regular expression. Any route that doesn't start with 'ajax/' should be redirected to the 'main'-router. Like so: $route['regexmagichere'] = "main"; So this is definetly way beyond my regex skills and I need some help. The regex s...

How do I avoid having to go two levels deep in CodeIgniter before I can parse URL segments?

Hi. I'm developing a game fansite to learn CodeIgniter that includes a database of character information. I want to use this URL format: http://www.mydomain.com/characters/joe http://www.mydomain.com/characters/sam So I have a controller called characters. If I understand the CI documentation, I can only parse "joe" and "sam" in t...

What's a good way to handle post data in Codeigniter?

I.e. would you recommend me to use one controller method like this: function save() { if(!is_bool($this->input->post('')) { $post_data = $this->input->post(''); $this->mymodel->save($post_data); } $this->load->view('myview'); } Or would you recommend writing it using two methods? function save() { ...

Can a model house multiple functions querying different domains?

I have a domain for users that connects to my user table, which includes information like username, first name, and last name. Then I have a domain for emails, that connects to the email table because a user can have more than one email. The email table consists of a fk to connect the user with their emails, and other fields like addres...

auto hyper-link

Hello I am trying to auto generate pages. What I am trying to do is make a upload form for an image upload that's displayed in a gallery. I have this but I then want each image to have a page hyper-link auto made for each image where the image can be seen bigger with buying information that's also been uploaded to a MySQL table not 10...

AJAX - Codeigniter

Hi all, Having gone through all the exisiting questions, I could not find a solution to the problem I was facing. I have a Codeigniter application, which on one of it's views has a form which makes a AJAX call to submit data. I have the Jquery code working for two AJAX calls but for one of the calls, from what I monitor in the header ...

CodeIgniter Controller problem

Hello, This is my AdminBase.php <?php class AdminBase extends Controller{ public function __construct(){ parent::Controller(); $admin = $this->session->userdata('username'); if(!isset ($admin)){ redirect('/Site/Home'); } } } And this is my Admin Controller :- <?php class Admin ...

how to crop image in codeigniter ?

Hello i'm using codeigniter to build a project and right now i need to create a thumb depending on user choice. like he will give me X1,Y1,X2,Y2,X3,Y3,X4,Y4 i want to crop the image depending on that 4 points. i checked the image manipulation class. the crop function seems to be very strange. any help please ? ...

Passing an array of data into a function (model). Please help!

Hello! I am using Codeigniter to pass an array of data from a controller into a model for insertion into the database. The code in the controller looks like this: $result = $this->items_model->add( array( 'ite_owner' => $this->post('user'), 'ite_type' => $this->post('type'), 'ite_value_1' => $this->post('va...

Getting $_GET to work with Codeigniter

I've seen several examples but i can't seem to get it working. Config.php: $config['uri_protocol'] = "PATH_INFO"; $config['enable_query_strings'] = TRUE; Library: class MY_Input extends CI_Input { function _sanitize_globals() { $this->allow_get_array = TRUE; parent::_sanitize_globals(); ...

CodeIgniter :: how to resize and watermark image without saving it to hard disk

I'm having a problem: I want to resize and watermark an image in CodeIgniter. But I need "dynamic_output" to be TRUE. $this->image_lib->resize(); $this->image_lib->watermark(); But when resize function fires it returns the image directly. I don't need to save the image to save temporary copy. Any help? ...

SimpleTest with CodeIgniter -- won't identify file -- variables die?

I am trying to use SimpleTest with CodeIgniter, using code supplied by maroonbytes. I am using LAMP and NetBeans 6.9. The test.php page loads up in my browser. I have a stub test in place and it shows in the drop-down selections. When I try to run it, I get 2 PHP errors: Message: include_once(/var/www/sparts3/main/tests/basic...

Error :Function must be terminated with a string in CodeIgniter's constants.php

Hello, While writing this line :- define('APPLICATION_ROOT', $_SERVER('DOCUMENT_ROOT') ); in constants.php in CodeIgniter framework of PHP i get error Error :Function must be terminated with a string. Can i not use Super Global arrays in constants.php? ...

html_entity_decode() isn't working properly?

EDIT: I solved it seconds after posting the question (sorry!) but can't accept an answer yet. Hi folks, Just a quick one. I have a PHP/CodeIgniter site and the user can edit their profile. I'm using CI's XSS Filtering and Active Record-based Models, so the data is escaped automatically. It naturally displays fine on the profile page v...