Welcome Guest, Not a member yet? Register   Sign In
  Array validation
Posted by: El Forum - 06-24-2008, 08:41 PM - Replies (6)

[eluser]EEssam[/eluser]
Hello,

I'm using CI validator and I need to validate an array. It looks like this into my view file:

<input type="text" value="order[1]" name="one">
<input type="text" value="order[2]" name="one">
<input type="text" value="order[3]" name="one">

$rules['order'] = "numeric"; is not working. I need to show the error if any field doesn't contain a number.

Please help.


  CodeIgniter Screencast : Igniting CSS files
Posted by: El Forum - 06-24-2008, 08:38 PM - Replies (4)

[eluser]Référencement Google[/eluser]
I just finished a quick screencast for beginners.

It shows:
- How to include CSS, images and Javascript files to your application
- How to remove index.php from url's with a .htaccess

I warn everybody that my english is bad (I am from Switzerland) and sometimes my words can be technically approximative due to a bad translation, but I think I am "understandable".

Get it here:
http://www.filepanda.com/file/stefy2w8w4i0/
After download, unzip it somewhere on your computer and launch the HTML file.

Enjoy!


  Blaze Htaccess error
Posted by: El Forum - 06-24-2008, 08:29 PM - Replies (2)

[eluser]Bnoe[/eluser]
i am try to install blaze cms
i got an error

when access
http://localhost/blaze/admin/ => work fine
http://localhost/blaze/admin => redirect to http://localhost/admin

my .htaccess

Code:
RewriteEngine On
RewriteBase /blaze/

# Add Trailing Slash (Force it!) - It looks cool :)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://localhost/blaze/index.php/$1/ [R=301,L]

# Admin ‘dashboard’
RewriteRule ^admin$ index.php/admin/ [L]
RewriteRule ^admin/$ index.php/admin/ [L]

# Admin functions within Admin module and controller
RewriteRule ^admin/(navigation|users|settings|login|logout)$ index.php/admin/$1 [L]
RewriteRule ^admin/(navigation|users|settings|login|logout)/(.*)$ index.php/admin/$1/$2 [L]
RewriteRule ^admin/nav_(.*)$ index.php/admin/nav_$1 [L]

# All others, push to the module in question
RewriteRule ^admin/([a-zA-Z]*)$ $1/admin [L]
RewriteRule ^admin/([a-zA-Z]*)/(.*)$ $1/admin/$2 [L]

# Any request were the file or directory doesn’t exist…
# Push to CI
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]


  load image and css file
Posted by: El Forum - 06-24-2008, 08:20 PM - Replies (3)

[eluser]123XD[/eluser]
Hey,

I have some problem with loading images and css file using CI6.0

I have directory structure like this

www
-sytem
--application
---views <- (all my web pages)
----css <- (all my css files)
----images <- (all my images for website)


my question is where does dir 'css' and 'images' should locate so it won't affect even I change my domain name. Like for any web server i just need to directly upload files and it should just work.

- How to config the base_url, I am lost.
- And how to get rid of the index.php, I have seen some articles about IIS url rewrite,
but I sitll can't make it work



Thanks in advanced.


  Functions Do Not Load Correctly?
Posted by: El Forum - 06-24-2008, 08:01 PM - Replies (1)

[eluser]amw_drizz[/eluser]
I am witting out an application and working on a multi page registration form. And when the 1st registration page loads with my template/theme correctly. Then when you load the user verification that dispatches an email with a link to click and verify the account and to continue the template/themes do not load and just loads the text that is generated from the system to populate the template/theme.

the first form function

Code:
function NewUserFormA()
    {
        $this->themechooser->GetTheme();        

        $this->load->helper(array('form', 'url'));
        $rules['username'] = "callback_username_check|required|min_length[5]|max_legnth[12]|xss_clean";
        $rules['password'] = "required|matches[password1]|md5";
        $rules['password1'] = "required";
        $rules['email'] = "required|matches[email1]|valid_email";
        $rules['email1'] = "required";
        $rules['fname'] = "required|xss_clean";
        $rules['lname'] = "required|xss_clean";
        $rules['street'] = "required|xss_clean";
        $rules['city'] = "required|xss_clean";
        $rules['state'] = "required|xss_clean";
        $rules['zip'] = "required|xss_clean";
        $rules['tos'] = "required";
        $fields['username'] = "Username";
        $fields['password'] = "Password";
        $fields['password1'] = "Password Retype";
        $fields['email'] = "Email";
        $fields['email1'] = "Email Retype";
        $fields['fname'] = "First Name";
        $fields['lname'] = "Last name";
        $fields['street'] = "Street";
        $fields['city'] = "City";
        $fields['state'] = "State";
        $fields['zip'] = "Zip Code";
        $fields['tos'] = "Terms of Service";
        if($_SERVER['REMOTE_ADDR'] == '10.0.0.21'){
            $this->validation->set_rules($rules);
            $this->validation->set_fields($fields);            
            $data['captcha'] = 'not required';
        }
        else{
            $rules['recaptcha_response_field'] = 'required|callback_check_captcha';
            $fields['recaptcha_response_field'] = "Captcha Image Verification";        
            $this->validation->set_fields($fields);
            $this->load->library('recaptcha');
            $data = array(
              'captcha' => $this->recaptcha->recaptcha_get_html()
            );
            
            $this->validation->set_rules($rules);
    
            // Function to check to see if captcha is correctly submitted
            
            function check_captcha($val) {
              $this->recaptcha->recaptcha_check_answer($_SERVER["REMOTE_ADDR"],$this->input->post('recaptcha_challenge_field'),$val);
              if ($this->recaptcha->is_valid) {
                return true;
              } else {
                $this->validation->set_message('check_captcha','Incorrect Security Image Response');
                return false;
              }
            }
        }
        $this->validation->set_error_delimiters('<div class="error">', '</div>');
        if($this->validation->run() == FALSE ){
            $this->load->view('reg/forma',$data);
        }
        else{
            $this->Proc_New1();
        }
    }
That works

This doesn't
Code:
function authenticate(){
        $this->themechooser->GetTheme();        
        $id = $this->uri->segment(3);
        $hash = $this->uri->segment(4);
        $query = $this->db->query("SELECT * FROM users WHERE id='". $id ."' AND reg_hash='". $hash ."'");
        if($query->num_rows() == 1){
            $row = $query->row_array();
            $str['active'] = 'yes';
            $str['lvl'] = '2';
            $this->db->where('id',$id);
            $this->db->update('users',$str);
            $data['base'] = base_url();
            $data['msg'] = "Okay Continue";
            $data['login'] = base_url().'auth/login';
            $this->parser->parse('reg/continue',$data);
            
        }else{
            $data = array(
                'header' => "Error!",
                'msg' => 'Some problems came up, either you waited to long and your account was removed or the link is invalid',
                );
            $this->parser->parse('reg/problem',$data);
        }
    }

Using the same function from my class/library that is loaded and working to get the template to use.

Any Ideas why it does not work on the second one?


  Book - CodeIgniter for Rapid PHP Application Development (David Upton) Problem
Posted by: El Forum - 06-24-2008, 06:57 PM - Replies (11)

[eluser]bennyhill[/eluser]
I am going through this book and the author has this defined on page 189
$this->load->library('errors');

then uses what I think is a function from it on page 194
$this->failure($message, 'sites');

I get errors when I run this, codeigniter says it can't load that library. And for the life of me I cannot find anywhere in the book where he creates this library or defines any failure function.

This book if from 2007. IS it possible that there use to be an errors library native to CodeIgniter and that it is not there anymore in the current build? Anyone that is familiar with this book please let me know.

Thanks


  Validation callback issue
Posted by: El Forum - 06-24-2008, 04:03 PM - Replies (5)

[eluser]EEssam[/eluser]
Hi,

I have something like this in my controller:

...
$rules['parentid'] = "callback_parental_check";
...

function parental_check($parent)
{

}

It's working fine but I need to pass another parameter for parental_check function to compare it with $parent variable. How can this be done?

Thanks.


  abandoning GET vars?
Posted by: El Forum - 06-24-2008, 03:43 PM - Replies (6)

[eluser]Unknown[/eluser]
Hello all,

I have a question about using CI that I hope I can state simply. I have built numerous web applications that use GET vars extensively, and I am trying to understand how a similar application would work under CI - using it out of the box, without enabling the GET vars feature.

Imagine a list view of financial forecast items for a given month. You can filter this view by office or by department, by salesperson, or combinations of these. You can also click on next month or previous month, and the filter must stick ( if you are looking at the Chicago office, you will still only see Chicago after clicking the "next month" link). This approach means many different GET vars could be used simultaneously to produce a filtered view, and that view could be "sticky" over different months.

an example url:

Code:
www.mydomain.com/forecast.php?mo=12&yr=2007&office=chicago&dept=sales&salesperson=bill

Under CI I could pass various URI segments to the controller function to replicate the functionality...but it appears to me they would always need to be in the same order for you to be able to map them to the correct "filter" option inside your controller function. They would not always appear in the same order, if for example you did not want to filter by office, only by dept. or by salesperson/dept, etc. Also, unlike a GET var it does not get passed as a name/value pair. I considered using URI segments such as "/dept.sales/office.chicago/" and splitting those variables inside the function to get the correct mapping, so the order in which they were passed to the function wouldn't matter. But there could be up to 7+ filters - it starts to get a bit clunky.

I suppose there is an option to use sessions to capture what "filters" are active, but with that approach you must "build" a filter to view it, and one would be unable to send someone a link that captured that entire view in the URI.

I certainly am not an expert and could easily be missing something obvious here about CI. Apologies for a long post and thanks for any thoughts you might have on how this could best be structured!

Doug


  ? in URLs
Posted by: El Forum - 06-24-2008, 02:38 PM - Replies (6)

[eluser]pgsjoe[/eluser]
I apologize if I missed where this was posted already or if it's in the User Guide, but I seem to have run into a slight problem here. Got my entire company's website up and running using CodeIgniter...it's beautiful. But now, they want me to implement some snippets of code for this Web Form Tracking software (it does more than Google Analytics, so NOT using their service isn't really an option) and the company has come back telling me:

"the snippet of code that we need to have on your site needs to allow for the '?' symbol. However, I noticed when I tested your Web Tracking that your code does not allow for this character. In order for web tracking to work, you’ll need to allow for this character."

Are there any solutions to this problem? I'm still fairly new to CodeIgniter, so I'm not sure how to handle this. Thanks in advance.


  form upload question
Posted by: El Forum - 06-24-2008, 02:09 PM - Replies (9)

[eluser]karloff[/eluser]
I've edited this post as i solved the last problem, i can't pass the image path into the database. I'm sure it fairly simple but can't get the syntax correct

i get this error

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined index: image

Filename: controllers/admin.php

Line Number: 96
A Database Error Occurred

Error Number: 1136

Column count doesn't match value count at row 1

INSERT INTO entries (title, image, pub_date, body) VALUES ('test work',NULL, NOW(),'test comments go here', 'http://codeigniter.com/')

not sure why it won't pass the image path to db, i followed the user guide (well i thought so, obviously i've gone wrong some where

here is part of my controller
Code:
...............
    function work_list()
    {
        $this->db->orderby('pub_date', "desc");
        $data['query'] = $this->db->get('work');    
        $this->load->view('admin/work_view', $data);
        $this->db->orderby('pub_date', "desc");


    }    

    function work_add()
    {
    
    $this->load->view('admin/work_add_view');
    
    }
    
    
    function work_insert()
    {


        $config['upload_path'] = './images/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '100';
        $config['max_width']  = '380';
        $config['max_height']  = '130';
        $field_name = "image";

        $title = $_POST['title'];
        $body = $_POST['body'];
        $image = $_POST['image'];
        $url = $_POST['url'];        


//        $this->upload->work_insert($image);
        $this->load->library('upload', $config);
        $this->db->query("INSERT INTO entries (title, image, pub_date, body) VALUES (".$this->db->escape($title).",".$this->db->escape($image).", NOW(),".$this->db->escape($body).", ".$this->db->escape($url).")");
    
        redirect('admin/work_list');
    

        
        
        
    }..................
and here's my view
Code:
&lt;?php $this->load->view('header'); ?&gt;

<p>&lt;?=anchor('admin/main', 'Back to Main'); ?&gt;</p>

<h2>Work Details</h2>
    &lt;?=form_open('admin/work_insert')?&gt;
        <fieldset>
            <legend>Entry Details</legend>
                <li><label>Headline</label></li>
                <li>&lt;?=form_input('title',''); ?&gt;</li>
                <li><label>Full Story</label></li>
                <li>&lt;? $data = array(
                      'name'    => 'body',
                    'style'   => 'width:100%',
                    );
                    echo form_textarea($data);
                 ?&gt;</li>
                 <li>&lt;input type="file" name="image" size="20" /&gt;</li>
                <li>&lt;?=form_input('url',''); ?&gt;</li>
                  <li>&lt;? $data = array(
                      'name'    => 'submit',
                    'class'   => 'submit',
                    'type'    => 'submit',
                    'value'    => 'Save changes',
                    );
                    echo form_submit($data);
                 ?&gt;</li>


        </fieldset>
    &lt;?=form_close(); ?&gt;

&lt;?php $this->load->view('footer'); ?&gt;

any help is much appreciated


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
SQL server connection not...
by kenjis
1 minute ago
Codeigniter Shield Bannin...
by xsPurX
8 minutes ago
Best way to create micros...
by kenjis
1 hour ago
How to use Codeigniter wi...
by kenjis
2 hours ago
Getting supportedLocales ...
by kcs
8 hours ago
Component help
by FlashMaster
Today, 01:41 AM
Show logo in email inbox
by WiParson
Today, 12:48 AM
Limiting Stack Trace Erro...
by byrallier
Yesterday, 02:21 PM
Bug with sessions CI 4.5....
by ALTITUDE_DEV
Yesterday, 01:36 PM
codeigniter 3.0.1 equiped...
by JustJohnQ
Yesterday, 10:05 AM

Forum Statistics
» Members: 85,225
» Latest member: mohdelfie24
» Forum threads: 77,576
» Forum posts: 375,975

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB