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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 12,101
» Latest member: mk_seven
» Forum threads: 68,418
» Forum posts: 426,830

Full Statistics

Latest Threads
Search engine PROBLEM: re...
Forum: General Help
1 hour ago
» Replies: 6   » Views: 124
Removing the index.php fi...
Forum: Installation & Setup
2 hours ago
» Replies: 9   » Views: 278
In the Database table for...
Forum: CodeIgniter 4 Support
2 hours ago
» Replies: 0   » Views: 31
How to show same view by ...
Forum: Model-View-Controller
2 hours ago
» Replies: 2   » Views: 344
step form wizard in php c...
Forum: General Help
2 hours ago
» Replies: 0   » Views: 29
hijacking \CodeIgniter\Co...
Forum: CodeIgniter 4 Support
3 hours ago
» Replies: 1   » Views: 36
Global Variable?
Forum: General Help
3 hours ago
» Replies: 2   » Views: 53
control based action in a...
Forum: General Help
7 hours ago
» Replies: 3   » Views: 87
Output is filled with war...
Forum: General Help
Yesterday, 06:59 PM
» Replies: 11   » Views: 174
Error 500 - Internal Serv...
Forum: General Help
Yesterday, 05:23 PM
» Replies: 2   » Views: 58

 
  CI not refilling form fields
Posted by: El Forum - 09-12-2007, 07:46 AM - Forum: Archived General Discussion - Replies (7)

[eluser]PeterB[/eluser]
Hi,

I've just started with CI (have to write PHP4 code for a project... boo) and have been trying to get form validation to work, on a componentised basis. My controller looks like:

Code:
class Signup extends Controller {

    function __construct()
    {
        parent::Controller();
        #if (!$this->site_sentry->is_logged_in()) {redirect('login/', 'location');exit;}
        $this->load->helper('date');
        $this->load->helper('form');
        $this->load->library('validation');
        $this->load->model('subscribers_model');
        $this->load->model('plans_model');
    }

    function index()
    {


        $data['plans'] = $this->plans_model->getAll(); // activate the option


        $data['form_details'] = $this->load->view('subscribers/_form_details', '', true);
        $this->load->view('subscribers/_form_details_validation.php', '', FALSE);
        
        $data['form_paymentplan'] = $this->load->view('signup/_form_paymentplan', $data, true);
        $this->load->view('signup/_form_paymentplan_validation.php', '', FALSE);
        
        
        if ($this->validation->run() == FALSE) {
            $this->load->view('signup/signup', $data);
        } else {
            // Breaks MVC as this should be encapsulated int he Subscirbers model?
            $newSubscriber = array(
                'firstname' => htmlspecialchars($this->input->post('firstname'), ENT_QUOTES),
                'lastname' => htmlspecialchars($this->input->post('lastname'), ENT_QUOTES),
                'email' => htmlspecialchars($this->input->post('email'), ENT_QUOTES),
                'password' => htmlspecialchars($this->input->post('password'), ENT_QUOTES),
                'status' => 'pending'
            );
            // make insertion, grab insert_id
            if ($this->db->insert('subscribers', $newSubscriber)) {
                $subscriber_id = array('subscriber_id'  =>  $this->db->insert_id());
                $this->session->set_userdata($subscriber_id);
            } else {
                die ($this->lang->line('error_problem_inserting'));
            }
            redirect('signup/payment/', 'location');
        }
        #$this->load->view('signup/signup', $data);
    }
}?>

_form_details looks like
Code:
<p>
    <label for="firstname">&lt;?php echo $this->lang->line('subscriber_firstname'); ?&gt;</label>
    &lt;input type="text" name="firstname" value="&lt;?php echo $this-&gt;validation->firstname; ?&gt;">
</p>
<p>
    <label for="lastname">&lt;?php echo $this->lang->line('subscriber_lastname'); ?&gt;</label>
    &lt;input type="text" name="lastname" value="&lt;?php echo $this-&gt;validation->lastname; ?&gt;">
</p>
...

And the validation code in _form_details_validation is
Code:
&lt;?php
$rules['firstname'] = 'trim|required|max_length[50]';
$rules['lastname'] = 'trim|required|max_length[50]';
$rules['email'] = 'trim|required|max_length[100]|valid_email';
$rules['password'] = 'trim|required|matches[password_confirm]|md5';
$rules['password_confirm'] = 'trim|required';
$this->validation->set_rules($rules);

$fields['firstname'] =  $this->lang->line('subscriber_firstname');
$fields['lastname'] =  $this->lang->line('subscriber_lastname');
$fields['email'] =  $this->lang->line('subscriber_email');
$fields['password'] =  $this->lang->line('subscriber_password');
$fields['password'] =  $this->lang->line('subscriber_password_confirm');
$this->validation->set_fields($fields);

$this->validation->set_error_delimiters('<p class="error">', '</p>');

Now... when I run it the form displays properly, and I can submit the form no problem (yes it goes back to the same method in the controller, I've checked). It even validates the data and displays error messages.

However... the specified $fields values aren't used in place of the field names, and it won't repopulate the form with data. This is using CodeIgniter 2.5.4, following the documentation that came with it. Is there a known problem, or have I done something silly?

Thanks,
Peter


  Testing connection to database
Posted by: El Forum - 09-12-2007, 06:10 AM - Forum: Archived General Discussion - Replies (3)

[eluser]Unknown[/eluser]
Hi,
In a page I would like to have a user test fill in the connection parameters to a database and then test them to see if the database is online. Is there a way that I could do that with CodeIgniter ?
I' masking that because when I'm trying a database connection that doesn't work I get the default CI exception message.


  validation class with multiple pages
Posted by: El Forum - 09-12-2007, 05:18 AM - Forum: Archived General Discussion - Replies (3)

[eluser]Unknown[/eluser]
hi, i am new to CodeIgniter.
i am using Validation class with 4pages forms like this

page1 -> page2 -> page3 -> page 4

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

if ($this->validation->run() == FALSE) {
//show errors
} else {
//to next page
$this->page2();
}

function page2(){...}
function page3(){...}
function page4(){...}

it works fine with page1, but not page2 nor page3, page4
when i use redirect insteed of $this->page2(), validation works fine but $_POST[] returns "NULL";

Code:
redirect('page2', 'location');

is there any way i can use Validation class with multiple pages??

please help me!!
thanks


  Can't POST
Posted by: El Forum - 09-12-2007, 05:14 AM - Forum: Archived General Discussion - Replies (4)

[eluser]ouzodestructo[/eluser]
I have developed a site and have put it on my web server but my forms don't post any data.
Have a look at http://www.geneethics.org/contact.

I have put in a print_r($_POST) in my controller to show whats passing (nothing!)

It works on my dev box, so why not here? I have brought it up with my web hosts but they say its not them.

Any ideas whats going on here?


  url and config
Posted by: El Forum - 09-12-2007, 04:12 AM - Forum: Archived Development & Programming - No Replies

[eluser]wojtekk[/eluser]
i made in config dir web.php

Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
    $CI =& get_instance();
    $CI->load->helper('url');
    
    $config['dir_images'] = base_url().'images/';
?&gt;

and in autoload.php
Code:
$autoload['config'] = array('web');

i did it like that because i dont think u should put anything more to config.php
i just want in one place directory (so icould change it easily) and just call
Code:
$this->config->item('dir_images')

I saw Assets Helper
but
structure of dirs on all pages not always the same
so
Code:
$config['dir_images'] = 'images/';
or
Code:
$config['dir_images'] = '/images/';
is correct

so add base_url() to link is the best solution
Correct me if im wrong and maybe there is other better solution


  Rewrite on name
Posted by: El Forum - 09-12-2007, 01:52 AM - Forum: Archived General Discussion - Replies (4)

[eluser]iniweb[/eluser]
I'am very interesting how work controller on: http://codeigniter.com/news/ and this rewrite: http://codeigniter.com/news/codeigniter_154_released/

Please show me controller ):


  combining 2 different application
Posted by: El Forum - 09-12-2007, 12:01 AM - Forum: Archived Development & Programming - Replies (3)

[eluser]dedenf[/eluser]
Hi,

i'm trying to combine 2 different application in one url, i have 1 apps that displaying and manage the newsite its powered by codeigniter, and the other apps is the file sharing application. i try to combine that 2 application but i got stuck in the uri path.
http://example.com/ << news site
http://example.com/appshare/ << file sharing application

appshare is meant to be a subdirectory url path from the "DocumentRoot" of the example.com not as the controller (appshare controller), how do i combine it without calling appshare as the controller? this is like escaping the appshare directory from the CI frameworks.
i've been looking around but have not found the answer yet.

thanks a lot


  Where Clause does not limit result set
Posted by: El Forum - 09-11-2007, 05:04 PM - Forum: Archived Development & Programming - Replies (1)

[eluser]Henry Weismann[/eluser]
I need a model to grab results based on a where clause but when the variable (customer_id) of the where clause is not given I want it to give an empty result set.

Should I be checking whether customer_id is empty before running the model function and if it is set $data to an empty quote or can I have the model take the empty variable and return an empty set.

The problem is if customer_id is empty when it is sent to the model function the whole table is returned as a result.

Model:

Code:
function get_stores($customer_id, $limit,$offset)
    {
    
        $this->db->where('customerName', $customer_id);
        $this->db->limit($limit,$offset);
        $query = $this->db->get('storeinfo');
        return $query->result();
    }

Controller
Code:
function moviesSold($invoice_id, $limit = 20, $offset = 0)
        {
        
        $customer_id = $this->customer_id ? $this->customer_id : $this->uri->segment(4);
        
        
        $data['store'] = $this->Customer_model->get_stores($customer_id,75,0);
.................................
................
..........
.....
..
.

How should I do this.


  Using a form + uri segments?
Posted by: El Forum - 09-11-2007, 04:30 PM - Forum: Archived Development & Programming - Replies (2)

[eluser]Dauntless[/eluser]
Hi,

I have a list of products (=catalog) where you can order the products by entering the amount and pressing 'order'. Now, you click the 'order' button directly from the product list (and not from a separate product-page). I have a controller function 'addToCart' that accepts 2 arguments: productID & amount. How can I put these things to getter? The user has to fill in a number (the amount), press 'order' and it should go to 'addToCart/productID/amount' .

Can this be done? Or do I have to rewrite the 'addToCart' function so that it processes $_POST ?

Greets,
Dauntless


  Javascript-Only Sites?
Posted by: El Forum - 09-11-2007, 12:17 PM - Forum: Archived Development & Programming - Replies (13)

[eluser]Vik[/eluser]
It seems like the site I'm developing would be much easier to use if I could do a user interface that requires the visitor to have Javascript. Here's why:

One of my pages will have about 20 popup menus on it. Depending on what the user selects in each one, a new, additional popup menu will appear, with its contents determined by what the user selected in the previous one.

With Javascript, I can (theoretically at least - I'm still working on the code) make this happen.

Without it, I'll have to have a different user interface - one that is more cumbersome for the user.

I looked up how many browsers have Javascript enabled (http://www.upsdell.com/BrowserNews/stat_trends.htm). It seems to be 95%:

Quote:Java and JavaScript Trends

This discusses trends in Java and JavaScript usage.
Summary

A significant number of users have browsers in which Java or JavaScript are not enabled. The percentage has decreased somewhat over the years, but it will likely remain significant for years to come.
Recommendation

Java and JavaScript should generally not be used for things which affect a site’s functionality. They are best used to make a site look more attractive.
Details

You can find information about JavaScript, including which browsers support which versions of JavaScript, in Wikipedia.

TheCounter (Jun 2007) reports these levels of support:
[.....]
Users JavaScript Support
5% none/disabled
95% enabled

Sites which need Java or JavaScript to function will deter users who have disabled them, therefore such sites will have more visitors with scripting enabled, but exact percentages likely will depend a lot on the site, and such percentages are not available.

But this quote also says, "JavaScript should generally not be used for things which affect a site’s functionality."

So the question is, with 95% of web browsers using Javascript, why is it a mistake to rely on Javascript for a site's functionality?



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.