Welcome Guest, Not a member yet? Register   Sign In
  how to use model?
Posted by: El Forum - 10-12-2008, 09:14 PM - Replies (22)

[eluser]syntaxerror[/eluser]
hi,
how to use model in developing application?
i know how to use controller and view, and my script is all controller and view.

any tutorial or just basic tutorial in using model?

thanks


  session vars created by a non CI php pages
Posted by: El Forum - 10-12-2008, 08:54 PM - No Replies

[eluser]Unknown[/eluser]
Hi,
I am starting to incorporate the CI framework on an existing system, which is created with just php scripts - with no framework at all.

The existing system has already a way of creating session vars and cookies.

Is it possible to get the session vars (created by non-CI pages) in the CI controller/pages? How?

I searched the forum but I cant find the answer.


Anyone?

Your help would be greatly appreciated.

ci_coder
:-)


  redirect() ignores my .htaccess and uses domain_name/index.php/<redirected_url>
Posted by: El Forum - 10-12-2008, 08:02 PM - Replies (3)

[eluser]Unknown[/eluser]
I'm new to codeigniter. My url's are working properly, aka trunk.dev/login/ Till I began working on the login/authentication for my application. When I call the redirect() function to redirect when authentication fails it redirects properly but uses the index.php so my url address points to -> http://trunk.dev/index.php/login instead of trunk.dev/login/

Any thoughts?

Below are my settings.

.htaccess

Code:
RewriteEngine On
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]


apache-conf
Code:
<VirtualHost 127.0.0.1:80>
   ServerAdmin [email protected]
   DocumentRoot "/www/project"
   ServerName trunk.dev
   <Directory '/www/project'>
        Options All
        AllowOverride All
   </Directory>
   ServerAlias www.trunk.dev
   ErrorLog "/private/var/log/apache2/trunk-error_log"
</VirtualHost>

lastly, my code calling the function
Code:
$handshake = $this->User_model->authenticate($email, $password);
if(!empty($handshake)){
   //authentication success
   redirect('user/', 'location');
} else {
   //throw error because authentication failed and redirect user to loginForm
   redirect('login/', 'location');
}


  CI vs. PDO vs. ADOdb vs. PEAR::DB
Posted by: El Forum - 10-12-2008, 06:10 PM - Replies (2)

[eluser]a&w[/eluser]
Anyone know how CI's database abstraction compares to the others? I'm guessing it may not support myriads of db's out there like some of the others (who cares as long as it supports the 'typical' ones?), but how about speed?

I saw where it looks like Zend Framework uses PDO. I saw some entries in the wiki a need to use PDO and ADOdb (http://adodb.sourceforge.net/) .... perhaps because people wanted to use other classes?

Why did CI reinvent the wheel (if it did?)? I came across some links looking around I'm just including for (my) reference:

Speed comparison (see end for summary)
http://joseph.randomnetworks.com/archive...-vs-adodb/
http://www.tonylandis.com/articles/php-a...chmark.htm
http://www.zfforums.com/zend-framework-c...b-223.html
http://brian.moonspot.net/2006/08/06/mys...y-version/
http://www.slideshare.net/trogers1884/ad...esentation
http://codeigniter.com/wiki/PDO_SQLite3/
http://codeigniter.com/wiki/ADODB/


  Basic checkbox validation not working - grad students + please help!!!
Posted by: El Forum - 10-12-2008, 05:40 PM - Replies (6)

[eluser]CIfan1000[/eluser]
I have the following controller:

Code:
&lt;?php

class Checkboxtest extends Controller {

    function index()
    {

        // Load CI helpers required for form validation:
        $this->load->helper(array('form', 'url'));

        // Load the validation library:
        $this->load->library('validation');
        
        // Define the validation rules for each field:
        // The names must be the field names in the form:
        $rules['CheckboxUserAgreement']     = "isset";
        
        $this->validation->set_rules($rules);
        
        // Repopulate the form field with the submitted data
        // The array keys are the actual names of the form fields,
        // the value represents the full name that you want shown in the error message.
        $fields['CheckboxUserAgreement'] = 'User agreement checkbox';

        $this->validation->set_fields($fields);
        
        $this->validation->set_message('isset', 'Please Accept Terms');

        if ($this->validation->run() == FALSE)
        {
            // If validation is false then (re)display the form:
            
            $data['title'] = "Registration";
            $data['bodyview'] = "register/checkbox";
            $this->load->view('templates/template01',$data);
            
        }
        else
        {

                    $data['title'] = "Registration successful";
                    $data['bodyview'] = "register/registersuccess";
                    $this->load->view('templates/template01',$data);
        }

    }

}
?&gt;

With the following view:

Code:
<h1>Checkbox test</h1>

&lt;?php

    // Version record
        // register01.01.01
            // Added checkbox

    // This line is required by the controller to display
    // validation errors in the form:
    echo $this->validation->error_string;

    // Create a form using CI
    // Validation and reshowing this form is handled by the controller
    // The argument for the form_open function must be the name of the Controller:
    echo form_open('checkboxtest');
    
?&gt;


    &lt;input type="checkbox" name="CheckboxUserAgreement" value="1" &lt;?php echo $this-&gt;validation->set_checkbox('CheckboxUserAgreement', '1'); ?&gt; />

    I have read and agree to the User Agreement<br/><br/>

    <div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

    &lt;/form&gt;

And I do not get a validation message if I do not check the checkbox and press Submit.

I did at one time when I had the validation rule originally set to "required" and it worked.

The problem with using "required" originally was that the validation message was "

The User agreement checkbox field must have a value.

I would like it to say: The User agreement checkbox field is required.

So then I changed it to "isset". That didnt work (no validation message).

Then I changed it back to "required" and now this also doesn't provide a validation message.

Maybe a bug?

I have spent 6 hours today trying different things including writing the above code to isolate it only to a checkbox.

I have also tried a callback function that also doesnt work.

I am starting to tear my limited amount of hair out!!!

Any help I would be very grateful for!!!!!


  auto loading custom configuration files which override config.php
Posted by: El Forum - 10-12-2008, 02:52 PM - Replies (1)

[eluser]blasto333[/eluser]
Is is considered normal behavior that I should be allowed to override values in the config.php file with my custom configuration files? I am centralizing all the settings for my application in one file, so the user does not have to go all over the place to set it up.

Code:
&lt;?php
$config['company']="Muench Inc!!";
$config['address']="";
$config['phone']="585-555-5555";
$config['email']="[email protected]";
$config['fax']="";
$config['website']="http://www.chrismuench.com";
$config['other']="";
$config['db_host']="localhost";
$config['db_name']="pos";
$config['db_user']="root";
$config['db_password']="******";
$config['default_tax_rate']="8";
$config['currency_symbol']="$";
$config['language'] = 'english';
?&gt;


  validation of a checkbox using the "required" rule
Posted by: El Forum - 10-12-2008, 02:48 PM - Replies (6)

[eluser]CIfan1000[/eluser]
If in my controller I have the following validation of a checkbox:

$rules['CheckboxUserAgreement'] = "required";

Then, if the checkbox is not checked, the view containing the checkbox displays:

The User agreement checkbox field must have a value.

I would like it to say: The User agreement checkbox field is required.

Please help.


  Email Config Bug Report
Posted by: El Forum - 10-12-2008, 02:30 PM - Replies (4)

[eluser]Unknown[/eluser]
I've encountered the same bug as these people in this thread.
http://ellislab.com/forums/viewthread/82683/

I also tried renaming email.php to Email.php as encountered in this thread - no luck
http://ellislab.com/forums/viewthread/89514/

Supposedly the userguide on the email class says you can create a $config array in /config/email.php and it should work however it does not.

/config/email.php

Code:
$config['smtp_host'] = 'smtp.mindspring.com';

/config/autoload.php

Code:
$autoload['config'] = array('email', 'redux_auth');
$autoload['libraries'] = array('database', 'email', 'validation', 'redux_auth');

Email Code


Code:
$this->email->from('[email protected]', 'Your Name');
        $this->email->to('[email protected]');

        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');

        $this->email->send();
        echo $this->config->item('smtp_host');
echo $this->email->print_debugger();

I even set it to autoload the config and it doesn't work.

This is what I get when printing the debug call.

Quote:You did not specify a SMTP hostname.
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

Note, I tried sending email via php's native mail() function and it worked fine.

Thanks


  callback on checkbox not working
Posted by: El Forum - 10-12-2008, 02:17 PM - Replies (1)

[eluser]CIfan1000[/eluser]
Hi guys!

I have the following in a controller:

Code:
// Define the validation rules for each field:
        // The names must be the field names in the form:
        $rules['RegisterUsername']         = "trim|required|min_length[5]|max_length[12]|xss_clean|alpha_dash";
    $rules['RegisterUserEmail']         = "trim|required|valid_email";
    $rules['RegisterUserPassword']     = "trim|required|min_length[5]|max_length[12]|xss_clean|alpha_dash|md5";
    $rules['RegisterUserPassword2']     = "trim|required|min_length[5]|max_length[12]|xss_clean|matches[RegisterUserPassword]|alpha_dash|md5";
    $rules['CheckboxUserAgreement']     = "callback_CheckboxUserAgreement_validate";

And then later in the same controller:

Code:
// ----------------------------------------------------------------------------
        // Define callback function used in validation above:
       function CheckboxUserAgreement_validate($str)
           {
                // Check if the CheckboxUserAgreement is checked:
                if (isset ($_POST ["CheckboxUserAgreement"]))
                    {
                        echo "true";
                         return TRUE;
                    }
                else
                    {
                     $this->validation->set_message('CheckboxUserAgreement_validate', 'You must agree to the User Agreement');
                     return FALSE;
                    }

            // End of CheckboxUserAgreement_validate function
            }

But the callback function does not seem to get called.

Any assistance or other suggestions as to how to validate a single checkbox would be very much appreciated. Thanks!


  Application Security
Posted by: El Forum - 10-12-2008, 12:08 PM - Replies (1)

[eluser]blasto333[/eluser]
I know this is probably the 3rd or 4th thread discussing this issue, but I have looked at all the previous solutions and have not been able to get security I want for my application.

Goal: To have a base controller to encapsulate security for all other controllers in application. Controllers can simply extend the base controller and it would take care of making sure the user is logged in.

The problem I am having, is redirect never gets called and the output is "I shouldn't get here"

application/libraries/MY_Controller.php

Code:
&lt;?php
class MY_Controller extends Controller
{
    function MY_Controller()
    {
        parent::Controler();
    }
    
}


class Secure_Area extends MY_Controller
{
    function Secure_Area($module_id=null)
    {
        parent::Controller();    
        $this->load->model('User');
        if(!$this->User->is_logged_in())
        {
            redirect('login');
        }
        
        if($module_id!=null)
        {
            if(!$this->User->has_permission($module_id))
            {
                die('You do not have permission to access this module');
            }    
        }
        
    }
    
}
?&gt;
application/controllers/home.php

Code:
&lt;?php

class Home extends Secure_Area
{
    function Home()
    {
        parent::Controller();    
    }
    
    function index()
    {
        echo 'I shouldn\'t get here';
    }
}
?&gt;


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

Username
  

Password
  





Latest Threads
problem with textarea
by Nitin Arora
3 hours ago
Showing pdf on browser
by aarefi
4 hours ago
[4.5.1] Disabling the deb...
by keto
6 hours ago
directory structure
by badger
7 hours ago
Redirect with error vali...
by pippuccio76
7 hours ago
Pass custom variables to ...
by InsiteFX
9 hours ago
How to run a single seede...
by kenjis
Yesterday, 05:41 PM
Codeigniter 4 extend core...
by kenjis
Yesterday, 05:26 PM
blocked by CORS policy
by kenjis
Yesterday, 05:17 PM
[CodeIgniter 4 on IIS 10]...
by Bosborne
Yesterday, 12:33 PM

Forum Statistics
» Members: 84,310
» Latest member: margaretsmith
» Forum threads: 77,553
» Forum posts: 375,875

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB