Welcome Guest, Not a member yet? Register   Sign In
  Where's Forge?
Posted by: El Forum - 07-02-2007, 07:31 PM - No Replies

[eluser]dshafer[/eluser]
I listened to the podcast about CI this morning and the speaker mentioned Rapyd and Forge as great plug-ins for CI. I found Rapyd and I'm studying it. I thought Forge was cited as a class for creating, validating and managing forms but I can't seem to find it by searching the site.

Can someone point me to it, please?

Thanks.


  Validation prep_for_form
Posted by: El Forum - 07-02-2007, 06:57 PM - No Replies

[eluser]Aaron L.[/eluser]
Hello,

I am trying to submit my form to a function which validates my form before inserting it into the DB. In this function, I am attempting to use prep_for_form (documentation). The problem is, when I fill-in the form with something like "I'm", I still get an SQL error because the ' is there.

Here is my code:

Code:
$this->load->library('validation');

    //set the validation rules
    $rules['subject'] = "prep_for_form|required|xss_clean";
    $rules['message'] = "prep_for_form|required|xss_clean";
    $rules['to_nick'] = "trim|required|xss_clean";
            
    $this->validation->set_rules($rules);
            
    //set field names for validation error messages
    $fields['subject'] = 'Subject';
    $fields['message'] = 'Message';
    $fields['to_nick'] = 'To Nickname';

    $this->validation->set_fields($fields);
            
    if ($this->validation->run() == FALSE)
    {
        echo "Error";
    }
    else
    {  
                $this->db->query("INSERT INTO messages (subject, message) VALUES ('$subject','$message')");

                echo "SUCCESS!!";
    }

Do you know what's going on here? I'm stumped...

Aaron


  My Simple JS to set "active" Menu
Posted by: El Forum - 07-02-2007, 05:16 PM - No Replies

[eluser]the real rlee[/eluser]
Here's a simple bit of JavaScript which sets the currently active link. Perhaps someone could build this into a helper or library

JS:

Code:
/*
@author: Richard Lee aka the real rlee
A simple JavaScript to set "active" class to active menu item based on url
*/
initMenu = function(){
    
    var url = "<?=site_url($this->uri->uri_string())?>";
    var menu = document.getElementById('main-nav').getElementsByTagName("A");
    
    for( var x = 0; x < menu.length ; x++ ){
        
        if (menu[x].href == url) {
            menu[x].className = 'active';
        }
      }
}

if (window.addEventListener) {
    window.addEventListener('load', initMenu, false);
} else if (window.attachEvent) {
    window.attachEvent("onload", initMenu);
}

</script>
HTML:
Code:
<ul id="main-menu">
  <li>
    &lt;?=anchor('home', 'home')?&gt;
  </li>
  <li>
    &lt;?=anchor('about', 'about')?&gt;
  </li>
  <li>
    &lt;?=anchor('locations', 'locations')?&gt;
  </li>
</ul>


  Model/Controller Quick Question
Posted by: El Forum - 07-02-2007, 04:21 PM - No Replies

[eluser]ikim[/eluser]
Hi,

Im starting to learn how to keep all database stuff inside models and separate it from the controllers. However, Ive been looking around and I cant seem to understand how to insert data into the database.

Right now I have a small form in my view sending the form to the controller.

Code:
function insert()
{        
$this->load->model('Test');
$this->Test->insert_info();
}

and then the model has
Code:
function insert_info()
    {    
        $data['user_id'] = $_POST['user_id'];
        $data['about_me'] = $_POST['about_me'];
        $data['tagline'] = $_POST['tagline'];
    
        $this->db->set('personality', $data);
     }


What am I missing? Ive been reading the user quide and trying to find something on the forum but I cant seem to find anything.

Thanks for the help


  Comment script at bottom of page
Posted by: El Forum - 07-02-2007, 03:50 PM - No Replies

[eluser]appelflap[/eluser]
Hi everybody!

I just started using CI a day ago and changed the code of small existing scripts to get an idea of the workings of CI. The website I have has a couple of controllers that display different things into an 'end view'. I'm not totally happy with the structure of the controllers/views.... I would like to know what the best way is to put a comment script at the bottom of all the controllers that can be viewed on my page. It will consist of a title/message box, a submit button and a list of previous comments to that specific controller.

Should I put the code into a PLUGIN and call it from the 'end view'? Or is there a much cleaner, better way for this?


PS.
Does somebody know a website that is built on CI and which has some controllers, helpers, which generates a front for which the main controller only generates the content AND! has a downloadable source? Smile The best way I learn structures is to see it right in front of me. The CI user guide is very nice, but it mainly covers very basic information.


  getting image dimensions
Posted by: El Forum - 07-02-2007, 03:45 PM - No Replies

[eluser]andyd[/eluser]
What is the best way to get the image dimensions of a gif or jpeg file on the server? Does the image manipulation helper offer function to provide these values, before trying to change the file.

Is it easy to get the image dimensions and resolution (width, height, dpi) with CI or PHP?

Kind regards

Andy


  url based sessions
Posted by: El Forum - 07-02-2007, 01:44 PM - No Replies

[eluser]Unknown[/eluser]
Hello everyone,

Please let me introduce myself in that section. I am a new user of CI and would like to ask if anybody tried to develope session system based on passing session ID in URL (I mean /controller/class/function/id/sess_id/ or similiar).

Recently I have faced a problem where some of customers claim to lose session data while switching between https<=>http pages on the same server. searching the web I have found that this is probably caused by deleted cookies during the above transtion (I am not sure if it is the whole true since I use the session_id passed in query string and still lost session occurs). The problem seems to be on client side since only some customers report this.

Please let me know the following issues:

1) using the controler/class/function/id system implemented in CI is it possible to pass sess_id between pages in a reasonable easy way

2) sice CI does not use GET variables has anyone tried to check https/http transition if it let preserve the url data

Regards


  Layout Library Redirecting Problem
Posted by: El Forum - 07-02-2007, 01:08 PM - No Replies

[eluser]Gurkan OLUC[/eluser]
Hi All,
I use Layout Library in my project. Evertyhing is okay but there is 1 problem which is the biggest one. I can't redirect with ci redirect() function because page gives me "headers already sent by" error message Sad codes are below,

Code:
&lt;?php
class Users extends controller {
    function Users() {
        parent::Controller();
        $this->load->model('user_model','user');
        $this->load->model('users_model','users');
        $this->load->model('other_model');
        $this->load->library('layout','layout_main');
    }

    //===================================================
    
    # Giriş Yap
    
    function login() {
        $username = $this->db->escape_str($this->input->post('username'));
        $password = md5($this->input->post('password'));
        if ( $this->users->beLogin ( $username, $password )) {
            $userID = $this->user->getUserID ( $username );
            $this->session->set_userdata('user_id', $userID );
            $this->session->set_userdata('username',$username);
            $this->session->set_userdata('login',true);
            if ($this->users->isFirstLogin ( $username )) {
                redirect('users/first_login');
            } else {
                redirect('/main');
            }
        } else {
            $data['message'] = 'Kullanıcı Adınızı Veya Şifrenizi Yanlış Girdiniz!';
            $data['redirect'] = base_url();
            $data['time'] = 5;
            $this->layout->view('message_view',$data);    
        }
            
    }
}

Thanks for help..

Note : before the load system switching I was loading views directly


  how to simultate a template with codeigniter
Posted by: El Forum - 07-02-2007, 11:12 AM - No Replies

[eluser]Unknown[/eluser]
Hello,
sorry my english is very bad because i am frenchspoken but this framework interest me very much i understood architecture but i want to load all my views in one file like a template or a pseudo-frame i look help please !
thanks


  How to make a good navigation ?
Posted by: El Forum - 07-02-2007, 11:10 AM - No Replies

[eluser]Diti[/eluser]
Good afternoon guys,

I was reading the article « Où suis-je », a translation of the Alistapart's “Where am I ?” when I wondered if CI is able to satisfy that :

Quote:Building in a lot of if/then statements to change the links per page takes some extra time. But it’s so worth it. Simply changing a global navigation item to be plain old text when you’re on that page means that it will look different (visual recognition of your present place) and will avoid the click-to-go-to-where-you-already-are bad experience.

Is that possible to follow all navigation principles thanks to CodeIgniter ?
My site follows the Derek Allard's sample website in coding techniques.

Oh, and could you read that : http://alistapart.com/articles/keepingcurrent Smile ?

Thanks.
Diti.


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

Username
  

Password
  





Latest Threads
Support to HTTP/3
by kilishan
43 minutes ago
Aw, Snap! : Chrome showin...
by JustJohnQ
4 hours ago
Best practice old vs set_...
by frocco
4 hours ago
Session data lost after r...
by pJenkiss
5 hours ago
Dinamic rule validation
by pippuccio76
8 hours ago
Validation Rules
by donpwinston
9 hours ago
Shared Models between mul...
by InsiteFX
9 hours ago
Use helper in validation
by InsiteFX
9 hours ago
Google Captcha implementa...
by davecoventry
11 hours ago
can temporary tables be u...
by richb201
Yesterday, 06:15 PM

Forum Statistics
» Members: 42,599
» Latest member: cryshelda12
» Forum threads: 75,482
» Forum posts: 367,593

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB