[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

CodeIgniter

40

Solutions

59

Contributors

CodeIgniter is an open-source software rapid development web framework used to build dynamic websites with PHP. The software is partly based on the model–view–controller (MVC) pattern, although models and views are optional. It is typically recognized for its speed when compared to other PHP frameworks.

Share tech news, updates, or what's on your mind.

Sign up to Post

i am new to codeigniter, just have 15 days of experience. i have to ask how to implement a div block of input type text for kids name, grade and course base on number of kids entered by parents??
i have a input type " number of kids" and based on that i want to display a div of level and input type according to number of kids entered like if parents entered 3 kids then i want a div with 3 labels and input type of name and grades...please help me
0
Rowby Goren Makes an Impact on Screen and Online
LVL 12
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

I had earlier posted about the PHP undefined variable issue i was facing, but i managed to solve it somehow and after that there is a small element that is not working if i could be helped with. So it is an online noticeboard system for a school and it has a users dashboard, teachers, and the admin. So the users dashboard is okay except when a user uploads a picture, it says not found technically i was having issues regarding the image as a undefined variable, and now it says not found. Earlier it was all working well.  also there is something about the user's updating password, when they update a password, says successful then when u log out and log in with the old password, i yet manage to log in with both old and new passwords. what could be the issue there?
Below is attached a screenshot for how the user dashboard looks like.
so here is the user's view for dashboard_header page:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Online Notice Board User Dashboard</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo 

Open in new window

0
Hello
I have a vps server with mysql apache andphp installed, and working codeigniter php script.
I have the SSh password. but I lost my phpmyadmin uername password.
What can I do?
0
Hi Experts

Could you point if  phpCAS that uses API for authenticating users against a CAS server (WebSSO CAS) could be integrated at an existing Codeigniter project?

CAS - Central Authentication Server

I'm implementing a SSO (Single Sign-On)  funcionality to allow a web app conexion based on user id and  correspondent user's data obtained from LDAP (AD-Active Directory)

phpCAS

I'm planning to implement the SSO functionality at PHP Codeigniter's site index.php.

Thanks in advance!
0
I keep getting this error every time I go to the chargeticket_list page.

Controller

public function chargeticket_list() {
$data['charge_tickets'] = $this->Chargeticket_model->list_charges($this->input->post('date1'), $this->input->post('date2'));
$this->load->view( 'inc/header' );
$this->load->view( 'chargeticket/chargeticket_list', $data );
$this->load->view( 'inc/footer' );
}

Open in new window

Model

public function list_charges($date1, $date2) //This function returns an array
    {   $this->db->join( 'customers', 'charges.idcustomers = customers.idcustomers' );
        $this->db->where('ch_date >=', $date1);
        $this->db->where('ch_date <=', $date2);
        $query = $this->db->get('charges'); //create query
        return $query->result_array(); //creates array from query
    }

Open in new window

View

<script type="text/javascript">

$(document).ready(function (){
    $('.date1').datepicker({
dateFormat: 'yy-mm-dd'});
});

$(document).ready(function (){
    $('.date2').datepicker({
dateFormat: 'yy-mm-dd'});
});
</script>

<div class="container">
<?php 
    $attributes = array('id'=>'chargeticket_list', 'class'=> 'form-horizontal');
    echo form_open('chargeticket/chargeticket_list', $attributes);
?>

<div class="form-group">
    <?php $ldata = array('class' => 'control-label col-sm-4');
    echo form_label('From','date1', $ldata ); 
    $data = array('class' => 'form-control date1','name' => 'date1');?>
    <div class="col-sm-4"><?php 

Open in new window

0
Hi Experts

Have an odd request to get done.  I have two applications, one in normal php (property application) and other in framework codeigniter (support application).  I need a way to be able to login from property app into support application automatically once logged into Property application.  Hope that makes...

When i click a link "support", goes to external application, and will prompt to login.  The same login credentials exist on both applications..and what needs to happen is some kind of login process based on the session from property app...that way a user would not have to login again..

Is this possible?
0
OK I think this is the weirdest yet.  To me, anyway.

If I leave in lines 3,4,5 the code appears to work (displays the array, shows no error).

If I comment out those lines, it fails
Severity: Notice

Message: Undefined offset: 0

Filename: models/Week_fixtures_model.php

Line Number: 490

if ( $query->num_rows() == 1)
		{
			echo "<PRE>";
			print_r($query->result_array());
			echo "</PRE>";
			$arr_venue_info['name'] = $query->result_array[0]['name'];
			$arr_venue_info['mapref'] = $query->result_array[0]['mapref'];
			return $arr_venue_info;	
		}
		else // no ground found.
		{
			$arr_venue_info['name'] = $venue;
			$arr_venue_info['mapref'] = 'No map';
			return $arr_venue_info;	
		}

Open in new window


Can anyone shed any light on this please?  I'm using CodeIgniter if that is relevant.
0
Parse error: syntax error, unexpected T_CONST in C:\wamp\www\codeigniter\system\core\CodeIgniter.php on line 58
0
Hi experts,
I need to reproduce this query in CodeIgniter, using ActiveRecord.  I've got very close but CI is putting backquotes where they are not wanted (the yellow-highlighted ones).
Here's the query and CI's interpretation of it...
query as interpreted by CIand here's the code I used to get it.  Part of this stems from CI's lack of support for UNION.
public function get_squad ($fixture_id, $side)
	{	
		$team_clause = 'X';
		if($side=='1') {$team_clause = ' p_1sts ';}
		if($side=='2') {$team_clause = ' p_2nds ';}
		if($side=='3') {$team_clause = ' p_3rds ';}
		if($side=='4') {$team_clause = ' p_4ths ';}
		if($side=='S') {$team_clause = ' p_sundays ';}
		if($side=='T') {$team_clause = ' p_sundays_res ';}
		if($side=='V') {$team_clause = ' p_young_vets ';}
		if($side=='W') {$team_clause = ' p_senior_vets ';}
		
		$this->db->select('first_name, surname, id AS "player_id", "Y" AS "player_picked", fp_keeper AS "keeper", fp_owes_subs AS "subs", fp_if_fit AS "fit", fp_if_available AS "available"');
		$this->db->from('fixtures_players');
		$this->db->join('players_members', 'fp_player_id = id', 'INNER');
		$this->db->where('fp_fixture_id', $fixture_id);
		$this->db->group_by(array('first_name', 'surname'));
		$first_half_inner_union = $this->db->get_compiled_select(); 		
		
		$this->db->select('first_name, surname, id AS "player_id", "N" AS "player_picked", "" AS "keeper", "" AS "subs", "" AS "fit", "" AS "available"');
		$this->db->from('players_members');
		

Open in new window

0
Weird!  Hopefully this is an easy 1000 points for someone.

This is taken straight from the manual, and I get an error - anyone see it?  I'm using CodeIgniter if that's relevant at all.

syntax error, unexpected '$v' (T_VARIABLE) in C:\xampp\htdocs1\fobg\application\controllers\week_fixtures.php on line 31

public function date_chosen()
      {            
            $a = array(1, 2, 3, 17);

            foreach ($a as $v) {
                echo "Current value of \$a: $v.\n";
            }
      }

also flagged up in Dreamweaver:
DW screenshot
0
Big Business Goals? Which KPIs Will Help You
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Hello experts,

I am trying to check if the post data obtained for 'fields' is empty. I have tried different conditions to check if the array is empty or not. Even if the 'fields' is empty, the if condition executes. It would be great if someone could suggest me as to how to go about with this.

View:
<h4>Alternatives</h4><input type="text" style="width:700px;display: inline" id="fields" name="fields[]" placeholder="Enter Method Name" class="form-control method_list_list"/> <input type="button" name="addmore" id="addmore" class="btn btn-success" value="Add More"/>

Model:
public function addmethodtotask(){
	 $conn= mysqli_connect("localhost","root","","cognitivewalkthrough");
	 $taskid=  $_POST['taskid'];
	$description =  $_POST['reason'];
	$action = $_POST['action'];

//if (isset($_POST['fields']) && $_POST['fields'] != "") {
	if (isset($_POST['fields']) && $_POST['fields'] != NULL) {
	// if (count($_POST['fields'])>0 && !empty($_POST['fields'])) {
		 echo "whey am i here";
				foreach ( $_POST['fields'] as $key=>$value ) {
					$sql_website = sprintf("INSERT INTO method (methodname,description,action) VALUES ('%s','%s','%s')",mysqli_real_escape_string($conn,$value),mysqli_real_escape_string($conn,$description),mysqli_real_escape_string($conn,$action) );
					$this->db->query($sql_website);
					$inserted_method_id = $this->db->insert_id();
				}
	}
        

Open in new window

0
I added codeigniter 'table' to my project and i got desired outcome for view except for the fact that the way i had it before i was able to delete record by clicking on them since they were anchor tags, i would like to know how to recreate this in new table format. Thanks!
site_model.php
site.php
options_view.php
Capture2.PNG
Capture.PNG
0
how to logout in php using codeignter
0
how to create login page in php using codeigniter
0
Hi Experts

Could you point a way to make a Codeigniter view have a very long timeout?

This view maintains a dashboard open in a TV during a long time. This dashboard presents information from time to time by using code like:

 $.getJSON("survey_dashboard/get_totais", function (data) {
	$.each(data, function (g, grupo) {
		if (grupo.GRUPO == 'TOTAL') {
			total = grupo;
		} else if (grupo.GRUPO == 'ATIVO') {
			ativo = grupo;
		} else if (grupo.GRUPO == 'RECEPTIVO') {
			receptivo = grupo;
		} else if (grupo.GRUPO == 'VIVO') {
			vivo = grupo;
		}
	});

Open in new window


Where
survey_dashboard/get_totais

Open in new window


is a Controller function  that calls a SP

...
  public function get_totais() {

        $data = array();
        $data = $this->survey_model->new_get(array('query' => "CALL proc_pesquisa_totais()"));
        die(json_encode($data));
    }

Open in new window


Because an user first need to login the system to charge the dashboard-  this start countnig time,  after the timeout is reached the dashboard closes.

Does CI has a way to extend this time?

Thanks in advance
0
Hi Experts

Could you point whyat's needed to a Codeigniter app to correctly be started?

When opened the app presents this screen

img006
And index.php must be fired to make it start.


Another app under the same htdocs present  the login screen but only correctly runs if index.php is used in the path.

Thanks in advance!
0
Hi Experts

Could you point what is preventing a Codeigniter app that is perfectly running localy to run in a remote server?

I'm facing this amazing occurrence:
When the complete app is locally copied and pasted under remote server htdocs folder, the adjustments are done in config.php and database.php

img001
config.php
// IP Configured
$config['base_url'] = 'http://10.xxx.x.223/meetasas_system/'

Open in new window


database.php is correctly pointing DB after some changes.

When the app is called the controller auth is not found... but it exists as the picture below shows.

Is it a matter of any other configuration?

Could you point a workaround?

Thanks in advance!
0
I have to solve this issue which I'm not able to solve :( I have a blog in PHP and an ecommerce site built with CodeIgniter. Both sites have the same session informations shared, but if I go on the blog and I login, when I pass on the ecommerce the user is not recognized and the ecommerce ask for a new login to the user.

In the blog part I set the session in this way:

<?php

include("config.php");

if(isset($_GET['logout'])){
    $servername = 'localhost';
    $username = 'wtgecomm_ecomm';
    $password = 'ElFDeOD$o_qd';
    $dbname ='wtgecomm_ecommerce';
    $conn = new mysqli($servername, $username, $password, $dbname);
     $sql = "DELETE FROM `ci_sessions` WHERE id="."'".$_COOKIE['ci_session']."'";
    if (!$conn->query($sql)) {
   // printf("Message d'erreur : %s\n", $conn->error);
}
    //$result = $conn->query($sql);
    //var_dump($result);
$_SESSION['login_id'] = '';
$_SESSION['customer_id'] = '';
unset($_SESSION['customer_id']);
unset($_SESSION['client']);
unset($_COOKIE['ci_session']);
session_destroy();
//var_dump($_SESSION);
header( 'Location: /'); 
}
if(isset($_REQUEST['login_id']) && !empty($_REQUEST['login_id']) ){

    $ci_session = $_COOKIE['ci_sessions'];
    $login_id = $_REQUEST['login_id'];
//  $sql = "INSERT INTO `ci_sessions` (`id`,`data`) VALUES ('2121212','121212121212')";
//  $ctx->exec($sql) ;
    $servername = 'localhost';
    $username = 'wtgecomm_ecomm';
    $password = 'ElFDeOD$o_qd';
    $dbname ='wtgecomm_ecommerce';
    $conn = 

Open in new window

0
How do I return the results of a query as JSON echo to screen?
0
IT Pros Agree: AI and Machine Learning Key
LVL 1
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Hi Experts


Could you point what's preventing a query that perfectly runs under MySQL IDE produces no result when running in PHP?

And what is needed to workaround it?


The query uses a special character in the where clause:

$analista = $where['like']['created_by'];
	
//     print_r($analista);
//            die;
	
	$query['query'] = "
			SELECT  
				sg.nome_seguradora as cliente_corporativo,
				DATE_FORMAT(data, '%d/%m/%y') as mes,
				it._name as analista,
				IF(interna_externa = 'I', 'Interna',IF(interna_externa ='E', 'Externa','-')) as interna_externa,
				enviado_por,
				nome_reclamante,
				IF(genero = 'M','Masculino',IF(genero = 'F','Feminio','-')) as genero,
				IF(fisica_juridica = 'F','Física',IF(genero = 'J','Jurídica','-')) as fisica_juridica,
				cpf_cnpj as cpf_cnpj,
				DATE_FORMAT(data_atendimento, '%d/%m/%Y') as data_atendimento,
				sise,
				cc.descricao as nome_produto,
				se.descricao as servico,
				su.descricao as sub_servico,
				cidade,
				uf,
				mo.motivo as motivo,
				de.descricao as origem_problema,
				bp.descricao as base_prestador,
				enviado_por as agente,
				DATE_FORMAT(enviado_dpto_em, '%d/%m/%Y %H:%i:%s') as enviado_dpto_em,
				DATE_FORMAT(resposta_dpto_em, '%d/%m/%Y %H:%i:%s') as resposta_dpto_em,
				responsavel,
				acoes_dpto,
				comentarios,
				parecer,
				DATE_FORMAT(recebido_em, '%d/%m/%Y %H:%i:%s') as recebido_em,
				DATE_FORMAT(respondido_em, '%d/%m/%Y %H:%i:%s') as respondido_em,
				

Open in new window

0
Hi Experts

Couls you point a way to make Codeigniter to consider the UTF-8 characters in config.php?

// Actually using
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

//I'm trying to avoid to accept every character here - only UTF-8
//$config['permitted_uri_chars'] = '';

Open in new window


Thanks in advance!
0
I like learning object oriented php

but do not want to be bogged down by html, css, jquery, javascript, ajax

I know I can use command line php but if a client is paying me; client usually wants artwork.
A css designer will draw a picture of an expected form and I am forced CODE the html and css to the exact layout of the picture

then the client states the the textbox is 1 inch (.5 cm) too tall.



do other object oriented languages force me to learn so much design software


Please add many other object oriented programming zones
0
Hi Experts


Could you point how to correctly present an array already obtained from CodeIgniter's model in the View?

Controller's code:
$this->data['fk_seguradora_f'] = $this->seguradora_model->get_seguradoras();

Open in new window


Model's Code:
function get_seguradoras( ) 
{ 
	$fk_seguradora_f = array();

	$query=$this->db->query("SELECT id_seguradora, nome_seguradora FROM system_seguradora");
	$fk_seguradora_f = $query->result_array();

	return $fk_seguradora_f;
}

Open in new window


View's code
<div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
				<i class="fa fa-search c-gray"></i>
			</span>
			<!--EF Jan/2017 - Campo de filtro dinamicamente formado --->
			 <span class="select">
				 <select id="fk_seguradora" name="fk_seguradora">
						<?php
						
                                               var_dump('testeyyy'); // just to locate the code easily.
						var_dump($fk_seguradora_f);
						die;
						
						
						foreach($fk_seguradora_f as $each)
						{
						?>
							<option value="<?=$each['id_seguradora']?>"><? echo $each['nome_seguradora']?></option>
						<?php
						}
						?>
				</select>
			  </span>
		</div>
	</div>
</div>

Open in new window


Debbuging, the array is correctly obtained in the view:
img001
The combo is functional but the names (nome_seguradora) doesn't appears.

img002Could you point a workaround on this?

Thanks in advance!
0
Hi Experts

Could you point a way to form a view's combo based on Codeigniter's results?

Accordingly to:

Controller's code:
public function index() {

	// SELECT/DROPDOWN - Seguradora
	$fk_seguradora = $this->cliente_corporativo_model->new_get(array('query' => 'select * from system_seguradora'));
	$dropdown[0] = 'Selecione ...';
	foreach ($fk_seguradora as $key => $value)
		$dropdown[$value->id_seguradora] = $value->nome_seguradora;

	$this->data['fk_seguradora'] = form_dropdown('fk_seguradora', $dropdown, '', 'id="id_seguradora"');
	unset($dropdown);
	
	...

Open in new window



View's code:
The values are actually "hard coded"
  <div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
				<i class="fa fa-search c-gray"></i>
			</span>
			<span class="select">
				<select id="fk_seguradora" name="fk_seguradora">
					<option value="" selected="selected">...Cliente Corporativo...</option>
					<option value="1">Ace</option>
					<option value="2">Zurich</option>
					<option value="3">Banco Safra</option>
					<option value="4">SANTANDER</option>
					....
				</select>
			</span>
		</div>
	</div>
</div>

Open in new window


I tryed to do this way:
<div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
					<i class="fa fa-search c-gray"></i>
			</span>
			<span class="select">
				<select id="fk_seguradora" name="fk_seguradora">
				
                                  // A for-each at this point makes sense?? - I guess there is a better option.
				   <option value="<?php $id_seguradora?>"><?$fk_seguradora?></option>
 
						
				</select>
			</span>
			</label>
		</div>
	</div>
</div>

Open in new window


Thanks in advance!
0
Hi Experts

Could you possibly give a help on how to configure Datatables plugin to make it correctly runs?

It's a Codeigniter project.
View code
<?php
             //datatables is a Codeigniter helper
		echo datatables(
				array(
			'id_servico' => 'ID',
			'descricao' => 'Descrição',
			  'acoes' => 'Ações',
                        // These lines must receive fake values otherwise Datatables doesn't load
			'a' => '',
			'b' => '',
			'c' => '',
			'd' => '',
			'e' => '',
			'f' => '',
		  
				),
				// Options dataTables
				array(
			'id' => 'datatables',
			'width' => '100%',
			'controller' => 'servico',
			'action' => 'datatables_list',
				),
				array(
			'like' => array(
				 'descricao'
			),
			'where' => array(
				'descricao'
			),
			'search_submit' => '.pesquisar_groups_form',
				)
		);

?>

Open in new window


Relevant part of datatables helper where the Datatable plugin is configured:
function redrawDataTables(where) {

	if (typeof table != "undefined" && typeof table != undefined && table != "") {

		$("#exemplo").empty();
		table.destroy();
	}

	if (typeof where == "undefined" || typeof where == undefined) {
		where = "";
	}
	   
	table =  $("#' . $options['id'] . '").DataTable({
		"paging":   true,
		// "pagingType": "scrolling",
		"pagingType": "full_numbers",
		// "sPaginationType": "four_button",
		"retrieve": true,
		"searching": false,
		"ordering": true,

		"order": [
			[ 
				' . $order . ', "' . $order_type . '"
			]
		],

		

Open in new window

0

CodeIgniter

40

Solutions

59

Contributors

CodeIgniter is an open-source software rapid development web framework used to build dynamic websites with PHP. The software is partly based on the model–view–controller (MVC) pattern, although models and views are optional. It is typically recognized for its speed when compared to other PHP frameworks.

Top Experts In
CodeIgniter
<
Monthly
>