Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14343 articles
Browse latest View live

how to route country region state

$
0
0
so this is my first post and would like to know how i would create a route 

so i have a country controller.

localhost/country/india

this page displays a list of regions in india.

so i have a controller 

localhost/region/southernindia

i want my url to look like this

localhost/india/southernindia

what would be best practice

hELP ME! Reporting sending to email ERROR

$
0
0
I am about to change my environment from development to production, however I still want to be made aware of any errors that may popup for any reason.

s there a way to catch any error with a class extension?

Search Filters

$
0
0
Hello i have a project where i want to add a filter in order to reduce the amount of entries shown to the user. I have added the option so that the user can select based on the year, but how can i pass that value to a variable in php. 
Here's a print screen :

.png   Screenshot_2.png (Size: 57.87 KB / Downloads: 1)

Codeigniter best script to start paid or not

$
0
0
Hi , I have developed a CI app for about 3 years ago and now I want a new start for it . I'm looking for a paid or not script that will help me start with the best standards. Most important things for me is secure login , ajax , user roles , jquery/bootstrap . It would be great if this app included ajax datatables , form builder. Basically I want and admin theme , but coded with CI . Looked everywhere , only found obsolete scripts . The best one I found and have worked with is SMA ( Stock manager advance) from envato and there is potential there but the code is kind of a mess .
My current app looks great , but in terms of scale is not great .
I want to start a CI app from a script with the best practices .

Font awesome alternative : Friconix

$
0
0
Hi, i developed a free alternative to Font Awesome : Friconix. This is a collection of free and beautiful icons for your website.

Note that Friconix is developed with CodeIgniter !

Moving CI2 to CI3

$
0
0
https://www.phpclasses.org/blog/package/...ml#convert

How to Convert MySQL to MySQLi

The project above is a wrapper that allows you to use old php mysql code with the new cli driver

Find the download, its 4 small files, 

I changed the name of mysql2i.class.php to mysql2i.class_helper.php  and put it in \application\helpers\.

Loaded it \application\config\autoload.php
$autoload['helper'] = array('gj','mysql2i.class');

and it did a nice job of allowing me to use my old php mysql code  

\application\config\database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'zCIDBclouda',
..
'dbdriver' => 'mysqli',

CodeIgniter logo

I create My_Model Like To Cakephp Core-CI

$
0
0
Hello, I made this library for CI a long time ago and it helps me in doing the Insert, Delete, Select, Procedure. to be able to execute the quickest queries.
but I still want to improve it so that it does not make requests and overload the queries.
application/core/ MY_Model.php  is my core in CI, this help me when i use the models
application/models/WebCampoSantos_model.php  for example how to use
application/controllers/Solicitacotizacionfb.php how to use the models  o in my controllers 

.php   MY_Model.php (Size: 45.7 KB / Downloads: 5)

.php   Solicitacotizacionfb.php (Size: 7.28 KB / Downloads: 4)

.php   WebCampoSantos_model.php (Size: 3.1 KB / Downloads: 4)

Can login even though the password is wrong

$
0
0
Hello, I just noticed that when I login into my system using a wrong password, I can still log in the system, but when I put a wrong username, I can't log in into the system. Can someone help me check what did i do wrong T_T. Thanks in advance ! 

Controller : 

Code:
    //login user
    public function login(){

        $data['title'] = 'Sign In';

        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        
        if($this->form_validation->run() === FALSE)
        {
            $this->load->view('templates/header');
            $this->load->view('users/login', $data);
            $this->load->view('templates/footer');
        } else {

            //Get username
            $username = $this->input->post('username');
            //Get and encrypt the password
            $password = $this->bcrypt->verify('password');



            // Login user
            $user_id = $this->user_model->login($username, $password);

            if($user_id){
                // Create Session
                $user_data = array(
                    'user_id' => $user_id,
                    'username' => $username,
                    'logged_in' => true
                );

                $this->session->set_userdata($user_data);

                // set message
            $this->session->set_flashdata('user_loggedin','You are now log in');

            redirect('home');

            }else {
                // set message
            $this->session->set_flashdata('login_failed','Login is invalid');

            redirect('users/login');

            }
        }
    }

Model : 

Code:
    //Login user in
    public function login($username, $password){
        $this->db->where('username', $username);
        $this->db->where('password', $password);

        $result = $this->db->get('omg_user');

        if($result->num_rows() == 1){
            return $result->row(0)->user_id;
        } else {
            return false;
        }

    }

custom bcrypt libraries : 

Code:
<?php

class Bcrypt {
 private $rounds;

 public function __construct($rounds = 12) {
   if(CRYPT_BLOWFISH != 1) {
     throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt");
   }

   $this->rounds = $rounds;
 }

 public function hash($input) {
   $hash = crypt($input, $this->getSalt());

   if(strlen($hash) > 13)
     return $hash;

   return false;
 }

 public function verify($input, $existingHash) {
   $hash = crypt($input, $existingHash);
   
   return $hash === $existingHash;
 }

 private function getSalt() {
   $salt = sprintf('$2a$%02d$', $this->rounds);

   $bytes = $this->getRandomBytes(16);

   $salt .= $this->encodeBytes($bytes);

   return $salt;
 }

 private $randomState;
 private function getRandomBytes($count) {
   $bytes = '';

   if(function_exists('openssl_random_pseudo_bytes') &&
       (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { // OpenSSL slow on Win
     $bytes = openssl_random_pseudo_bytes($count);
   }

   if($bytes === '' && is_readable('/dev/urandom') &&
      ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) {
     $bytes = fread($hRand, $count);
     fclose($hRand);
   }

   if(strlen($bytes) < $count) {
     $bytes = '';

     if($this->randomState === null) {
       $this->randomState = microtime();
       if(function_exists('getmypid')) {
         $this->randomState .= getmypid();
       }
     }

     for($i = 0; $i < $count; $i += 16) {
       $this->randomState = md5(microtime() . $this->randomState);

       if (PHP_VERSION >= '5') {
         $bytes .= md5($this->randomState, true);
       } else {
         $bytes .= pack('H*', md5($this->randomState));
       }
     }

     $bytes = substr($bytes, 0, $count);
   }

   return $bytes;
 }

 private function encodeBytes($input) {
   // The following is code from the PHP Password Hashing Framework
   $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

   $output = '';
   $i = 0;
   do {
     $c1 = ord($input[$i++]);
     $output .= $itoa64[$c1 >> 2];
     $c1 = ($c1 & 0x03) << 4;
     if ($i >= 16) {
       $output .= $itoa64[$c1];
       break;
     }

     $c2 = ord($input[$i++]);
     $c1 |= $c2 >> 4;
     $output .= $itoa64[$c1];
     $c1 = ($c2 & 0x0f) << 2;

     $c2 = ord($input[$i++]);
     $c1 |= $c2 >> 6;
     $output .= $itoa64[$c1];
     $output .= $itoa64[$c2 & 0x3f];
   } while (1);

   return $output;
 }
}

How to embed Audio/Video file in online exam system?

$
0
0
Guys,
    Need a support to develop a online examination project with audio and video embeded .

cannot able to clear cache files

$
0
0
I want to clear cache files . after removing history old page only be displayed. how to solve?
1,$this->output->delete_cache();
2,$this->output->clear_all_cache();
 i put in the controller error occured
Fatal error: Call to undefined method CI_Output::delete_cache() in C:\xampp\htdocs\*****\****\controllers\auth.php on line 16

csrf_exclude_uris not work

$
0
0
$config['csrf_protection'] = true;
$config['csrf_token_name'] = 'csrf_token_test';
$config['csrf_cookie_name'] = 'csrf_cookie_test';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array('/assistant_dashboard/upload.html');
Confused
I upload file to '/assistant_dashboard/upload.html' but the 'csrf_exclude_uris' not work.
Please show me how to do?

Inherited an CI project and am pretty lost with it.

$
0
0
Hello!

I inherited some old(?) CI project against my will and now I need to make some updates but I'm pretty lost with the configuration.

A little background: I know PHP and I've been using Drupal for like 10 or so years. I've done stuff with Joomla, WP, Symfony and plain PHP. I'd like to think myself as a PHP professional. I have also inherited stuff before that I had no prior experience with and always managed to get by.

But now I'm stuck with this. This is running live currently and we're at the planning stage of an new system but before we get that going, customer wants some changes to their CI application. There's no documentation to go by.

I have downloaded the code from live server to my local environment running Ddev based Docker setup. This setup has worked for Symfony, Drupal, Joomla & WP sites, so I'm assuming it should be fine for CI app as well.

I also have gone through the configs in system/application/config and tried to make necessary changes for local Docker env. I'm pretty sure I've got most things configured, since I do get DB connection and can see configs with xdebug. The system is also redirecting me to /login path which makes me think that atleast something works.

However, I'm completely stuck with some routing troubles. 

No matter what URL I try to access, I get redirected to /login with 404 error. In my log I see this:
Code:
ERROR - 2019-03-29 00:57:01 --> Severity: Notice  --> Only variables should be passed by reference /var/www/html/system/codeigniter/Common.php 150
DEBUG - 2019-03-29 00:57:01 --> Config Class Initialized
ERROR - 2019-03-29 00:57:01 --> Severity: Notice  --> Only variables should be passed by reference /var/www/html/system/codeigniter/Common.php 150
DEBUG - 2019-03-29 00:57:01 --> Hooks Class Initialized
ERROR - 2019-03-29 00:57:01 --> Severity: Notice  --> Only variables should be passed by reference /var/www/html/system/codeigniter/Common.php 150
DEBUG - 2019-03-29 00:57:01 --> URI Class Initialized
ERROR - 2019-03-29 00:57:01 --> Severity: Notice  --> Only variables should be passed by reference /var/www/html/system/codeigniter/Common.php 142
ERROR - 2019-03-29 00:57:16 --> 404 Page Not Found --> q

While debugging system/libraries/Router.php I can see that it tries to access URI "q". So perhaps there's something wrong with url rewriting?

TBH, I have a lot to learn with CI, but it would be easier if I'd get this app up locally to debug more.

From what I've read, CI is pretty loose with how you do stuff so I fear that this app may not have been coded following best practices. 

But if I get this up locally I'm pretty sure I can reverse-engineer how this CI app works.

So as I'm going through the documentation, I would really appreciate any input as to how to get this up and running.

Thanks for any advice.

/ Janne

Query num-rows missing?

$
0
0
Hello, please add the num_rows function in query result helper Smile
Thank you!

CI 3 and community auth

$
0
0
Hello,  I'm new to CI and Community Auth.  I've followed a tut I found on YouTube and it's working so far.  I was wondering if someone could give an assist on a registration feature to community auth.  So far I can see you can add users in the code ... but I was thinking of a view with a form to register.  I'm still getting my head wrapped around this MVC stuff so any assist would be greatly appreciated!

X

Hi Forum, I'm new in this forum, I want to say hello

$
0
0
Hello everyone, my name is Juan Manuel Pedro Villalba, I write this post to say hello.
 I want to tell you that I have marveled with Codeigniter because they have to know that in my search I have not found something similar.
 I've seen that laravel and sinfony there are interesting things, but create it! I do not dare to leave codeigniter !, I'm a Linux fanboy what I think most stands out Codeigniter is that it has something great, it is portable, easy to install "Copy & paste" , works with the minimum of memory, has great things that I am discovering and I hope to discover here as well.

My objectives in this forum is to learn, listen and gain more knowledge, to start contributing with everything I can, I would like to be advised where I can read the terms of the forum and I hope not to be violating their policies with this post.

I would like to hear from you and hear that I am advised to learn faster and what kind of tools "Libraries", helpers, "resources" and others that I can use to act quickly in programming.

I would appreciate your help with advice to boost my knowledge in developments and thus improve in every way.

How to talk with me: When they address to me remember that there are many things that I do not know, but I am willing to learn.

If you talk about some name that I do not know, I would appreciate your telling me its meaning, because I regret to tell you that my economic and social resources are scarce and if you give me a clue I will learn slowly.

What do I have "local hosting" to work?
I currently work with my computer in local mode a W10
With a linux debian 9 installed.
So I think I can move with more freedom than with a hosting account since my internet connections are very bad.

If you are willing to help me I will be super grateful.

A Database Error Occurred

$
0
0
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting the varchar value 'currInstl + 1' to data type int.

SELECT "custNo", "custName", "totalInstal", "InstallAmnt" FROM "fund" WHERE "status" = 'A' AND "branch" = 16 AND "totalInstal" > 'currInstl + 1' ORDER BY "custName" ASC



Ref (Sql Query works well)
=================
select custNo, custName, totalInstal, InstallAmnt from fund
where status='A' and branch=16 and totalInstal> currInstl+ 1
order by custName;

but not to works in codeigniter..Please help me

Database Forge Class does not create the table

$
0
0
Hi all,
I try to create table into my db but i can't. System give no error messages. Any suggestion? Smile


CONTROLLER
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Tables extends CI_Controller {
 
       public function __construct()
 
       {
 
               parent::__construct();
 
               $this->load->model('table_model');
 
       }
 
       public function index()
 
       {
 
               $fields = array(
 
                   'blog_id' => array(
 
                       'type' => 'INT',
 
                       'constraint' => 5,
 
                       'unsigned' => TRUE,
 
                       'auto_increment' => TRUE
                    
),
 
                   'blog_title' => array(
 
                           'type' => 'VARCHAR',
 
                           'constraint' => '100',
 
                           'unique' => TRUE,
 
                   ),
 
                   'blog_author' => array(
 
                           'type' =>'VARCHAR',
 
                           'constraint' => '100',
 
                           'default' => 'King of Town',
 
                   ),
 
                   'blog_description' => array(
 
                           'type' => 'TEXT',
 
                           'null' => TRUE,
 
                   ),
 
               );
 
               $this->table_model->create_table($fields);   
        
}


MODEL

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
class 
Table_model extends CI_Model {

 
   public function __construct()
 
   {
 
       $this->load->database();
 
       $this->load->dbforge();
 
   }
 
   public function create_table($data)
 
   {
 
       //print_r($data);
 
       $this->dbforge->add_field($data);
 
       $this->dbforge->create_table('mytable',TRUE);
 
   }

What’s Up

$
0
0
I’m 10 hours in the car with the kids., someone throw me something... What are you all working on? What do you plan to use CI4 for? Will you rewrite your CI3 app to use CI4 or not?

Problem With Checking Date Based Reservations

$
0
0
Hello everybody,

I have been working on a small, non-profit reservation & hotel management system for a friend and my problem is :

I have got 2 tables : rooms and room_activities (to store reservations on a daily basis)

rooms table :
room_id - room_no - room_capacity - room_situation

room_activities table :
room_acitivities_id - days - room_id - customer_id - rez_situation

My Problem :

When I submit a date to see the availability result(s),  I can easily see the booked room(s).

BUT I have problem about seeing the available rooms which are not booked, and also when I have more than 2 rooms booked for that day, my result starts to get crazy.


My View:
PHP Code:
<form action="<?php echo base_url('rooms/room_check_date'); ?>" method="post">
 
         <script>
 
         $(function() {
 
           $("#enter").datepicker({ dateFormat'yy-mm-dd' });
 
         });
 
       </script>

      <div class="input-holders">
          <label class="form-labels">ENTER DATE</label>
          <input type="text" name="enter_date" class="my-inputs" placeholder="Please Choose A Date" id="enter-date">
      </div><!--input-holders ende-->

        <div class="clr"></div>

        <button type="submit" id="submit-button-blue">Check It</button>
</form> 


My Controller :

PHP Code:
public function room_check_date(){

        
$enter $this->input->post('enter_date');

        
$this->load->model('Rooms_model');
        
$operation_result $this->Rooms_model->lets_check_availability($enter);
        
        
        if(
$operation_result){
         
   $this->load->model('Rooms_model');
         
   $data['availables'] = $this->Rooms_model->lets_check_availability($enter);
         
   
                    $this
->load->view('rooms/check-room-availability'$data);

        }else{
 
                   $some_errors "There are some errors";
         
   $this->load->view('rooms/check-room-availability'$some_errors);
            
        }

    } 

My Model  (First Unsuccessful Trial):

PHP Code:
public function lets_check_availability($enter){
 
        $this->db->select('*');
         $this->db->from('rooms as r');
         $this->db->join('room_activities as ra''r.room_id = ra.room_id''LEFT');
         $this->db->where('ra.days !='$enter);
         $this->db->group_by('ra.room_id');
         $lets_see $this->db->get()->result();

         return $lets_see;



The biggest problem here, besides the ones I wrote above, I couldn't see the rooms which have never been added to room_activities table.. So, it was not a room table based sql. And I tried another solution and could see the rooms which are not in room_activities table :

PHP Code:
$this->db->select('*');
$this->db->from('rooms as r''room_activities.ra');
$this->db->where('r.room_id NOT IN(SELECT room_activities.room_id FROM room_activities)');

$lets_see =$this->db->get()->result();
return 
$lets_see


How can I get the best result?
I would like to see the rooms which are available on a selected date.

Regards.
Viewing all 14343 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>