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

unique user id tie in with paypal

$
0
0
hi guys

i have a website with a service on it which works without a login system. i want to charge for it through payment gateway, how do i ensure that each session for the user is unique when multiple users access the same service?

example if user A inputs 2+2=?, then website redirects him to payment gateway after which result 4 is shown.
but while user A completes his session another user B comes in and wants to know 3+5= ?, say if i have a 100 users simultaneously starting sessions wanting to know their results how do i go about handling them?

jquery.min.js not working

$
0
0
Hello everyone,

I have been moved application from production to development mode in localhost and tried to run application, so far so good it's work but I have problem with linking JS and CSS, I googled and try a lot of option but generally my problem is get request 404 not found. I will attach screenshot. I am new at PHP programming especially codeigniter. Sorry if this topic is duplicate.

.png   codeigniter.png (Size: 31.72 KB / Downloads: 1)

"Remember Me" for regular CodeIgniter 4 sessions

$
0
0
Hello colleagues!

I am developing a simple free system of control of the site on CodeIgniter 4. I successfully implemented the basic functionality for control of the site, but i faced a problem that is difficult to solve myself. In all the systems that I saw, there is an option "remember me" in the form of authorization in the admin area. I looked at the framework documentation, and a bit of the source code of the session library, but I didn’t have any idea how to make the framework set up a cookie without a lifetime that only works until the browser is closed. Pay attention that the question is exactly how to do this dynamically, for a particular login, not the whole system.

I would appreciate the advice on how to do this without interfering with the source code of the framework.

If you want to help, or just watch the new system, then here is the link to the source code and installation instruction: https://github.com/basic-app/basic-app

Undefined property: CI::$encrypt

$
0
0
Hi,
I recently download a HMVC project from server to localhost. it works fine on online but when i setup it at localhost then some of pages doesn't show css/js.
i got the following error

<p>Severity: Notice</p>
<p>Message:  Undefined property: CI::$encrypt</p>
<p>Filename: MX/Controller.php

Thanks in Advance

Priority of routes using 'generic' add method

$
0
0
Hi,
I had an issue Confused that that a route defined with 'add' was given lower priority than a route defined with 'get' method.

Route definition:

$routes->get('news/create','News::create');
$routes->get('news/test','News::test');
$routes->get('news(/Confusedegment)?','News::view$1');


Order of route resolved in  \Codeigniter\Router\Collection\getRoute()

array (
  'news/create' => '\\App\\Controllers\\News::create',
  'news/test' => '\\App\\Controllers\\News::test',
  'news(/[^/]+)?' => '\\App\\Controllers\\News::view$1',
)



Route definition:

$routes->add('news/create','News::create');
$routes->get('news/test','News::test');
$routes->get('news(/Confusedegment)?','News::view$1');



Order of route resolved in  \Codeigniter\Router\Collection\getRoute() 

array (
  'news/test' => '\\App\\Controllers\\News::test',
  'news(/[^/]+)?' => '\\App\\Controllers\\News::view$1',
  'news/create' => '\\App\\Controllers\\News::create',
)

Reviewing the code, this appears to be by design.

if (isset($this->routes[$verb]))
{
  // Keep current verb's routes at the beginning so they're matched
  // before any of the generic, "add" routes.
  if (isset($this->routes['*']))
  {
     $extraRules = array_diff_key($this->routes['*'], $this->routes[$verb]);
     $collection = array_merge($this->routes[$verb], $extraRules);
  }
  foreach ($collection as $r)
  {
     $key          = key($r['route']);
     $routes[$key] = $r['route'][$key];
  }
}



Although I don't necessarily agree with the rational behind this design decision, I think it would be create to document this in the user guide.

Not sure how to contribute to this, but willing to make pull request for the doco if someone can point me in he right direction on how to do this.

Thanks to anyone who can assist on this.

Error Unable to De-Activate Account when registering a new user

$
0
0
After updating to Ion-Auth 3, I'm getting the error
Code:
Unable to De-Activate Account
when trying to register a new user.

Here is the code I'm calling.

PHP Code:
$user_id $this->ion_auth->register($username$password$email$additional_data$group_ids);    
// $user_id returns false when doing a var_dump

// update the user requirements
if($user_id !== FALSE) {
 
 $this->session->set_flashdata('message',$this->ion_auth->messages()); // message confirming user was created 
 
 $this->requirements_model->update_user_requirements($this->input->post('requirements'), $user_id);

else {
 
 $this->session->set_flashdata('message'$this->ion_auth->errors());


Before I last updated (which was about two years ago) everything was working fine. I'm using email as the identity and I've followed the update guide in github.

What is causing that error? The message doesn't seem to be relevant. There are no users in the database with the email I'm trying to register.

Thanks.

Values in a function getting Nullified when calling SQL insert query

$
0
0
Hi Team
i am running into a weird problem. I have created a function to insert some data into the database. i am getting the values to be inserted from Angular. unless the insert or query function is called ($this->db->insert('table_name', $data_array), i can see all the values coming to the function correctly and i can also print those values but as soon as i call the insert / query function and i run the code, the values are showing NULL or 0. Could somebody please help me on this issue.

Code:
public function course_landing_page_data($courseTitle, $courseSubTitle, $ins_id) {


$data = array(
'course_title'      => $courseTitle,
'course_sub_title'      => $courseSubTitle,
'ins_id'   => $ins_id
);

print_r($data);



$sql = "INSERT INTO temp_courses (course_title, course_sub_title, ins_id) VALUES (".$this->db->escape($courseTitle).", ".$this->db->escape($courseSubTitle).", ".$this->db->escape($ins_id).")";
echo $sql;
$this->db->query($sql); <<<<<<<<<
$this->db->_error_message();
return true;

// }

}

appreciate your help

For development app

$
0
0
I am looking for interested IT people who would like to take part in the development of such a **Link redacted**. We can use it as an example, but do it on this platform. It will be much better because we will customize it to your needs. 
This offer will be especially interesting for beginners.

Library cross load issue

$
0
0
using ci 3.1.10

foo_library.php
PHP Code:
public function __construct() {
$ci =$ get_instance();
$ci->load->library('bar_library');



bar_library.php
PHP Code:
public function __construct() {
$ci =$ get_instance();
$ci->load->library('foo_library');



no problem in 3.1.6

but 3.1.10, infinity load library. Huh

23
0.0267
1406784
Foo_library->__construct( )
.../Loader.php:1285


24
0.0268
1411640
CI_Loader->library( )
.../Foo_library.php:23


25
0.0268
1411640
CI_Loader->library( )
.../Loader.php:202


26
0.0268
1411640
CI_Loader->_ci_load_library( )
.../Loader.php:218


27
0.0268
1412440
CI_Loader->_ci_init_library( )
.../Loader.php:1083


28
0.0268
1412544
Bar_library->__construct( )
.../Loader.php:1285


29
0.0268
1412544
CI_Loader->library( )
.../Bar_library.php:20


30
0.0268
1412544
CI_Loader->_ci_load_library( )
.../Loader.php:218


31
0.0268
1412624
CI_Loader->_ci_init_library( )
.../Loader.php:1063


32
0.0268
1412720
Foo_library->__construct( )
.../Loader.php:1285


33
0.0269
1412720
CI_Loader->library( )
.../Foo_library.php:23


34
0.0269
1412720
CI_Loader->library( )
.../Loader.php:202


35
0.0269
1412720
CI_Loader->_ci_load_library( )
.../Loader.php:218


36
0.0269
1412816
CI_Loader->_ci_init_library( )
.../Loader.php:1063


37
0.0269
1412920
Bar_library->__construct( )
.../Loader.php:1285


38
0.0269
1412920
CI_Loader->library( )
.../Foo_library.php:20

Pass Id getting from URL to many function in CodeIgniter

$
0
0
I am getting an ID from a url like:
Code:
<?php echo base_url();?>Product/product/<?php echo $product->id;?>"

In my sidebar on the same function[view -> Product/product] I am getting it correctly. but when I click some other function in my sidebar the Id is not coming like:
Code:
public function Product($id)
{
    $this->data['product'] = $this->prod->get_product($id);
   $this->load->view('products/header');
   $this->load->view('products/topnav');
   $this->load->view('products/sidebar',$this->data);
   $this->load->view('products/home',$this->data);
   $this->load->view('products/footer');
}

it is working on this page as expected, but when I jump to different function in my sidebar the id is not working because it is not getting it... like:
Code:
public function Data()
{
   $id=$this->Product($id);
   $this->data['product'] = $this->prod->get_product($id);
    $this->load->view('products/header');
   $this->load->view('products/topnav');
   $this->load->view('products/sidebar', $this->data);
   $this->load->view('products/data');
   $this->load->view('products/footer');

}

What I want: How to get the Id which I pass above to all my sidebar functions.

SQL Server Insert-Output issue

$
0
0
Greetings community!

I have hit a wall here. I'm working with SQL Server, which is not quite familiar to me but, I'm managing it.

Here's the problem. I'm sending these sql instructions in on single query like tihis:

Code:
$recno = $this->db->query('insert into dbo.SC0010 (R_E_C_N_O_)
         output inserted.[R_E_C_N_O_]
         select max(r.R_E_C_N_O_) + 1 from dbo.SC0010 r', false, true);


Which is working just fine, for most tables. I get what I want which is the new inserted RECNO. However one particular table has a trigger, which makes this instruction to fail and return an error. I've looked into the error and found a solution which works fine if I run the query in a SQL Manager tool, but it doesn't work on CI. Here's the query with the solution applied to it:


Code:
$recno = $this->db->query('DECLARE @PedItens TABLE ( [RECNO] INT)
         insert into dbo.ZL2010 (R_E_C_N_O_)
         output inserted.[R_E_C_N_O_] into @PedItens
         select max(i.R_E_C_N_O_) + 1 from dbo.ZL2010 i
         select RECNO from @PedItens', false, true);

I applied a print_r in $recno and the result is this:


Code:
CI_DB_sqlsrv_result Object ( [scrollable] => buffered [conn_id] => Resource id #48 [result_id] => Resource id #61 [result_array] => Array ( ) [result_object] => Array ( ) [custom_result_object] => Array ( ) [current_row] => 0 [num_rows] => [row_data] => )


The query runs without errror, the new RECNO is inserted but there's no rows returned in it.

Anyone has gone through this kind of problem? Any help would be welcome.

Thank you.

ow can I get the unique nodeNames into an array?

$
0
0
I have an XML like this in my Codeigniter project


Code:
<myitems>
 <myitem>
   <myname>Some Name</myname>
   <myphone>4444444</myphone>
 </myitem>
 <myitem>
   <myname>Some other Name</myname>
   <myphone>8888888</myphone>
 </myitem>
</myitems>

How can I get the unique nodeNames into an array, like array("myname","myphone") ?

set_update_batch how to plus 1

$
0
0
PHP Code:
$data = array(
        array(
            
'id' => 5,
            
'name' => 'test',
            
'visit' => '`visit` + 1'
        
),
        array(
            
'id' => 7,
            
'name' => 'wang',
            
'visit' => '`visit` + 1'
        
)
    );
$this->Test_model->set_update_batch($data'visit'false);
$this->Test_model->update_batch('table'$data'id'); 

but is don't work。

when use

PHP Code:
$update = array(
    
'id' => 7,
    
'name' => 'wang',
);
$this->Test_model->set('visit' 'visit + 1'false)->update($data); 

it's OK ,can you help me how to use set_update_batch and update_batch

Can I disable only database log?

$
0
0
I set $config['log_threshold'] = 1; in my production environment to log main errors. I use log_message('error', '....'); to register suspicious behavior in log file.

In my code a have a db->insert. This insert can produce a db error of duplicate key. This is not a problem for me, this can happen and my code check db_error to do the right actions. But every time I get a duplicate key error this is write in my error log and I don't want this. This is not a useful error for my app, so I would like this error is not reported in my log, I want all other errors, my errors (with log_message('error')) but not this error.

I set $db['default']['db_debug'] = FALSE; but nothing changed.

Then I tried to change it dinamically in this way:
$oldvalue = $this->config->item('log_threshold');
$this->config->set_item('log_threshold', 0);
$this->db->insert($this->table, $data);
....
$this->config->set_item('log_threshold', $oldvalue);

but I still see the error in my log file (I read other thread where someone wrote log path can't be dinamically changed, so I think also log_threshold can't be changed dinamically).

I know I can create a transaction, using insert ignore, etc. etc. but I want to know if I can do this with log settings

Database session frequently expired (before sess_expiration)

$
0
0
I'm using CI 3.1.10. I'm using database to save the sessions and here is my config:

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_admin_session';
$config['sess_expiration'] = 14400;
$config['sess_save_path'] = 'ci_admin_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 14400;
$config['sess_regenerate_destroy'] = FALSE;

I have tried setting $config['sess_time_to_update'] to 300 or 14400, also setting sess_expiration to 0 (never expired)

However session still expired way before sess_expiration. I have minimal ajax call and I can't seem to find the answer.

Can I convert empty strings to NULL with a Codeigniter validation rule?

$
0
0
I would like to convert all my POST values from '' to NULL automatically with a Codeigniter validation rule. Is it possible?
Here is my helper, which is working fine with text and numbers :

PHP Code:
function empty2null($value)
{
 
   return $value === '' null $value;



Can I define it as a validation rule (prepping?) somewhere? How to do this?
Afterwards I would like to send it as a proper NULL value to Doctrine.

I tried to implement it as a classic rules, but this custom function is not triggered when the POST value is empty.

Thank you

MY_I18n_Model

CodeIgniter:The page you requested was not found.

$
0
0
I am facing an issue with one of my website which was developed using CodeIgniter. I am new to CodeIgniter. A few days ago I have found an issue with my website, when i check my website performance in google webmaster tools it shows around 118 url which was developed automatically and when i click on a url it shows The page you requested was not found. I think It was created by some malicious code or sql injection. I don't know how to resolve it. Please help me.

.jpg   8.JPG (Size: 61.13 KB / Downloads: 0)

problem with response and entity

$
0
0
How do you do guys ? nice ? ok 'cause I have a problem Big Grin

if my model return and object Entity, If i ask in my controller the typeof $entity->createdAt, it answer CodeIgniter\I18n\Time Object ok nice (magical mutations and casts works) BUT....

if i do $this->response->SetJson($entity); i got an empty object. no cast, no magical conversions, all fields are protected so the json_encode can't access to this fields. The same with a var_dump or print_r. fields are not converted.


How can i send over a REST application the correct representation of my entity ?

Note :

If i put some fields"public" in my entity, i can see it in my response but without magical conversion...

is that a bug or a workaround ? maybe someone did this trick ?

the worst is that if i do $this->response->SetJson($entity->created_at); I've got an error 500 about a problem with format.

Code:
Argument 1 passed to CodeIgniter\Format\JSONFormatter::format() must be of the type array, object given, called in /www/api/system/HTTP/Response.php on line 551

preg_match() expects parameter 2 to be string, array given

$
0
0
I've problem with my controller and i need ur help  Big Grin
this is my syntax. I want to get data smtp_user from my DB:

$config['protocol']      =  "smtp";
$config['smtp_host']   =  "ssl://myweb.com";
$config['smtp_port']   =  "465";
$config['smtp_user']   =  $this->db->select('email')->get('tb_contact')->result();    // the problem is here----
$config['smtp_pass']  =  $this->db->select('password')->get('tb_contact')->result();    // the problem is here----
$config['mailtype']     =  "html";
$config['charset']       =  "iso-8859-1";
$config['wordwrap']   =  TRUE;

thank youu
Viewing all 14343 articles
Browse latest View live


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