Welcome Guest, Not a member yet? Register   Sign In
  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:
<?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');
            }    
        }
        
    }
    
}
?>
application/controllers/home.php

Code:
<?php

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


  Help with proper URL/URI setup
Posted by: El Forum - 10-12-2008, 10:46 AM - Replies (7)

[eluser]rt30000[/eluser]
I've spent some time trying to get this project halfway working to show my issues better than I can translate:

Here is the test URL: CI Project Link

As you can see, I just cannot figure out URLs or URIs. I have to use "index.php/page/index/4" (where 4 is the $id of the page to display) rather than a more friendly url. You can click through the pages, all the top level ones are there. The home page, because it has no $id (just goes straight to default controller "page") throws two errors. Ideally, I would like more clear urls and remove the index.php. I tried using .htaccess but I think my server is not accepting it. Is that the first step I need to solve?

I really appreciate any help you can lend me...this is my first stab at MVC. Everything on those pages is based off a single template (with sub views), a model and the Page controller. I think i'm beginning to understand the basic concept.

Here is my controller just in case it helps.

Code:
<?php

class Page extends Controller {
    
    function Page()
    {
        parent::Controller();
        $this->load->model('page_model');
    }
    
    function index($id)
    {
        /* Determine which page this is by using supplied id... */
        if (!$id) $id=1;
        
        /* Load necessary data for template */
        $template = $this->_setup_page($id);    
        
        /* Load master page view and pass along required template parameters ($template) */
        $this->load->view('master_view', $template);
    }
    
    function _setup_page($id)
    {
        $page_data = $this->page_model->get_page($id);
        $site_data = $this->page_model->get_site_info();
        
        $template['page_title'] = $page_data['page_title'];
        $template['body_class'] = $page_data['body_class'];
        if ($page_data['header_img'] <> '') {$template['header_img'] = base_url().'public/img/'.$page_data['header_img'];} else {$template['header_img'] = '';}
        $template['background_img'] = base_url().'public/img/'.$page_data['background_img'];
        $template['page_headline'] = $page_data['headline'];
        $template['page_headline_img'] = base_url().'public/img/'.$page_data['page_headline_img'];
        $template['page_content'] = $page_data['page_content'];
        $template['footer'] = $site_data['footer'];
        $template['display_featured_prod'] = $page_data['display_featured_product'];
        
        return $template;
    }
    
}

/* End of file page.php */
/* Location: ./system/application/controllers/page.php */

THANKS! rob


  $this->input->post() of array
Posted by: El Forum - 10-12-2008, 06:27 AM - Replies (8)

[eluser]Mitja B.[/eluser]
is it possible to get value from array with $this->input->post() function or i need standsrd $_POST[][] function.

Thx


  Why does the session id keep changing?
Posted by: El Forum - 10-12-2008, 06:03 AM - Replies (3)

[eluser]mvdg27[/eluser]
Hi,

I'm working with the session class, and I notice that the session id keeps changing. I'd actually prefer (or better I need) the session id to stay the same, once assigned. Can this behavior be changed?

Thanks is advance.

-Michiel


  calling get_instance() from external script
Posted by: El Forum - 10-12-2008, 04:41 AM - Replies (6)

[eluser]Yednotek[/eluser]
Is it possible to get a CI instance in an external script somehow like this:

Code:
function somefunction_in_standalone_script()
{
  $obj=&get;_instance();
}

The external script is an 3rd party script that generates an image but it uses sessions which I already use in CI. If the above is possible then this would be the easiest solution.


  Pagination.. using multiple segment variables
Posted by: El Forum - 10-12-2008, 02:28 AM - Replies (6)

[eluser]Drayen[/eluser]
Hey guys, kind of a dumb question here.

Three types of fruit:

Orange,Cherry,Apple

mysite.com/cherry/5

That's how the uri segments would set up, so everything works fine

but how would I program the controller to display ALL types of fruit?

mysite.com/all/5

would not return any results, so is there a way to do an if statement where if the uri segment equals something specific it does something, or is there an easy way to automate this? Obviously the way I have it now, it uses the uri segment variable to access the database, but if there's no variable there it will break the pagination.

Thanks for any help, sorry If I worded this poorly.


  How to get a database value to the config file?
Posted by: El Forum - 10-12-2008, 02:26 AM - Replies (2)

[eluser]geshan[/eluser]
I need a system with changeable themes, so I need to get the active/current theme from the database to the config file from where I can access it in helpers and controllers. How do I do it???


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

Username
  

Password
  





Latest Threads
Retaining search variable...
by pchriley
3 minutes ago
SQL server connection not...
by JustJohnQ
12 minutes ago
CVE-2022-40834 SQL Inject...
by reactionstudio
31 minutes ago
How to use Codeigniter wi...
by sr13579
44 minutes ago
Disable debug output in v...
by groovebird
52 minutes ago
CI 4.5.1 CSRF - The actio...
by kenjis
2 hours ago
CodeIgniter v4.5.0 Releas...
by kenjis
2 hours ago
Cache best practice?
by BhambriRohunu
4 hours ago
Bug with sessions CI 4.5....
by InsiteFX
4 hours ago
Codeigniter Shield Bannin...
by kenjis
9 hours ago

Forum Statistics
» Members: 85,312
» Latest member: getalinkvis
» Forum threads: 77,578
» Forum posts: 375,991

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB