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

how to handle csrf exception with ajax

$
0
0
Hello community members. In the documentation, i could not find an example for handling exception for ajax calls, as documentation is telling me that whenever csrf token fails, it will throw exception, but i could not catch exception by using the following code in my controller

try {
       //My Code here, I skipped here.
} catch (\CodeIgniter\Security\Exceptions\SecurityException $e) {
//I also tried catch in this way catch(\Exception $e) {, but didnot work
       //code to handle exception here
}

//Note that I am trying this with ajax calls only.


I always get this in reply
{
    "title": "CodeIgniter\\Security\\Exceptions\\SecurityException",
    "type": "CodeIgniter\\Security\\Exceptions\\SecurityException",
    "code": 403,
    "message": "The action you requested is not allowed.",
    "file": "/Users/qamarhafeez/www/pos/new-pos/system/Security/Exceptions/SecurityException.php",
    "line": 10,
    "trace": [
        {
            "file": "/Users/qamarhafeez/www/pos/new-pos/system/Security/Security.php",
            "line": 233,
            "function": "forDisallowedAction",
            "class": "CodeIgniter\\Security\\Exceptions\\SecurityException",
            "type": "::",
            "args": []
        },
        {
            "file": "/Users/qamarhafeez/www/pos/new-pos/system/Filters/CSRF.php",
            "line": 88,
            "function": "CSRFVerify",
            "class": "CodeIgniter\\Security\\Security",
            "type": "->",
            "args": [
                {
                    "uri": {},
                    "config": {
                        "baseURL": "http://point-of-sale.localhost/new-pos/public",
                        "indexPage": "",
                        "uriProtocol": "REQUEST_URI",
                        "defaultLocale": "en",
                        "negotiateLocale": false,
                        "supportedLocales": [
                            "en"
                        ],
                        "appTimezone": "Asia/Karachi",
                        "charset": "UTF-8",
                        "forceGlobalSecureRequests": false,
                        "sessionDriver": "CodeIgniter\\Session\\Handlers\\FileHandler",
                        "sessionCookieName": "ci_session",
                        "sessionExpiration": 7200,
                        "sessionSavePath": "/Users/qamarhafeez/www/pos/new-pos/writable/session",
                        "sessionMatchIP": false,
                        "sessionTimeToUpdate": 300,
                        "sessionRegenerateDestroy": false,
                        "cookiePrefix": "",
                        "cookieDomain": "",
                        "cookiePath": "/",
                        "cookieSecure": false,
                        "cookieHTTPOnly": false,
                        "proxyIPs": "",
                        "CSRFTokenName": "csrf_token_name",
                        "CSRFHeaderName": "X-CSRF-TOKEN",
                        "CSRFCookieName": "csrf_cookie_name",
                        "CSRFExpire": 7200,
                        "CSRFRegenerate": true,
                        "CSRFRedirect": true,
                        "CSPEnabled": false
                    }
                }
            ]
        },
        {
            "file": "/Users/qamarhafeez/www/pos/new-pos/system/Filters/Filters.php",
            "line": 173,
            "function": "before",
            "class": "CodeIgniter\\Filters\\CSRF",
            "type": "->",
            "args": [
                {
                    "uri": {},
                    "config": {
                        "baseURL": "http://point-of-sale.localhost/new-pos/public",
                        "indexPage": "",
                        "uriProtocol": "REQUEST_URI",
                        "defaultLocale": "en",
                        "negotiateLocale": false,
                        "supportedLocales": [
                            "en"
                        ],
                        "appTimezone": "Asia/Karachi",
                        "charset": "UTF-8",
                        "forceGlobalSecureRequests": false,
                        "sessionDriver": "CodeIgniter\\Session\\Handlers\\FileHandler",
                        "sessionCookieName": "ci_session",
                        "sessionExpiration": 7200,
                        "sessionSavePath": "/Users/qamarhafeez/www/pos/new-pos/writable/session",
                        "sessionMatchIP": false,
                        "sessionTimeToUpdate": 300,
                        "sessionRegenerateDestroy": false,
                        "cookiePrefix": "",
                        "cookieDomain": "",
                        "cookiePath": "/",
                        "cookieSecure": false,
                        "cookieHTTPOnly": false,
                        "proxyIPs": "",
                        "CSRFTokenName": "csrf_token_name",
                        "CSRFHeaderName": "X-CSRF-TOKEN",
                        "CSRFCookieName": "csrf_cookie_name",
                        "CSRFExpire": 7200,
                        "CSRFRegenerate": true,
                        "CSRFRedirect": true,
                        "CSPEnabled": false
                    }
                },
                null
            ]
        },
        {
            "file": "/Users/qamarhafeez/www/pos/new-pos/system/CodeIgniter.php",
            "line": 382,
            "function": "run",
            "class": "CodeIgniter\\Filters\\Filters",
            "type": "->",
            "args": [
                "user/ajax_handle",
                "before"
            ]
        },
        {
            "file": "/Users/qamarhafeez/www/pos/new-pos/system/CodeIgniter.php",
            "line": 312,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->",
            "args": [
                null,
                {
                    "handler": "file",
                    "backupHandler": "dummy",
                    "storePath": "/Users/qamarhafeez/www/pos/new-pos/writable/cache/",
                    "cacheQueryString": false,
                    "prefix": "",
                    "memcached": {
                        "host": "127.0.0.1",
                        "port": 11211,
                        "weight": 1,
                        "raw": false
                    },
                    "redis": {
                        "host": "127.0.0.1",
                        "password": null,
                        "port": 6379,
                        "timeout": 0,
                        "database": 0
                    },
                    "validHandlers": {
                        "dummy": "CodeIgniter\\Cache\\Handlers\\DummyHandler",
                        "file": "CodeIgniter\\Cache\\Handlers\\FileHandler",
                        "memcached": "CodeIgniter\\Cache\\Handlers\\MemcachedHandler",
                        "predis": "CodeIgniter\\Cache\\Handlers\\PredisHandler",
                        "redis": "CodeIgniter\\Cache\\Handlers\\RedisHandler",
                        "wincache": "CodeIgniter\\Cache\\Handlers\\WincacheHandler"
                    }
                },
                false
            ]
        },
        {
            "file": "/Users/qamarhafeez/www/pos/new-pos/public/index.php",
            "line": 45,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->",
            "args": []
        }
    ]
}

Catch database exception

$
0
0
Hi,

I have some problems with catching a database exception. On the development, everything works as I expected but not on the production.

My code looks like below:

PHP Code:
        try {

            $orderStatus = new OrderStatus;

            $orderStatus->insert(new OrderStatusEntity([
                'order_id' => $orderId,
                'status_id' => $statusId
            
]));

        }
        catch (\mysqli_sql_exception $e) {

            if ($e->getCode() === 1062)
            {
                log_message('warning''Duplicate status ({status}) for order {id}', [
                    'status' => $statusId,
                    'id' => $orderId
                
]);
            }

        

On the development environment in the logs file, I have only `Duplicate status...` - as I want

On the production environment in the logs file, I have a raw exception

PHP Code:
ERROR 2020-10-13 20:25:22 --> mysqli_sql_exceptionDuplicate entry '441-2' for key 'order_id_status_id' in /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/MySQLi/Connection.php:331
Stack trace
:
#0 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/MySQLi/Connection.php(331): mysqli->query('INSERT INTO `or...')
#1 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/BaseConnection.php(741): CodeIgniter\Database\MySQLi\Connection->execute('INSERT INTO `or...')
#2 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/BaseConnection.php(669): CodeIgniter\Database\BaseConnection->simpleQuery('INSERT INTO `or...')
#3 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/BaseBuilder.php(2249): CodeIgniter\Database\BaseConnection->query('INSERT INTO `or...', Array, false)
#4 /var/www/mrsystem/vendor/codeigniter4/framework/system/Model.php(755): CodeIgniter\Database\BaseBuilder->insert()
#5 /var/www/mrsystem/bundles/Ecommerce/Order/Order.php(272): CodeIgniter\Model->insert(Array) 

If I changed in the Database config variable DBDebug to TRUE then I have a raw exception and logged a warning

PHP Code:
ERROR 2020-10-13 20:25:22 --> mysqli_sql_exceptionDuplicate entry '441-2' for key 'order_id_status_id' in /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/MySQLi/Connection.php:331
Stack trace
:
#0 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/MySQLi/Connection.php(331): mysqli->query('INSERT INTO `or...')
#1 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/BaseConnection.php(741): CodeIgniter\Database\MySQLi\Connection->execute('INSERT INTO `or...')
#2 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/BaseConnection.php(669): CodeIgniter\Database\BaseConnection->simpleQuery('INSERT INTO `or...')
#3 /var/www/mrsystem/vendor/codeigniter4/framework/system/Database/BaseBuilder.php(2249): CodeIgniter\Database\BaseConnection->query('INSERT INTO `or...', Array, false)
#4 /var/www/mrsystem/vendor/codeigniter4/framework/system/Model.php(755): CodeIgniter\Database\BaseBuilder->insert()
#5 /var/www/mrsystem/bundles/Ecommerce/Order/Order.php(272): CodeIgniter\Model->insert(Array)
(...)

WARNING 2020-10-13 20:38:20 --> Duplicate status (2) for order 441 

Can someone tell me what I am doing wrong? How to on the production environment get an only logged warning?

Query Builder's insert method return type

$
0
0
Hey there,

I'm trying to insert some data into a database using the Query Builder's insert method.

According to the documentation, the insert method returns a boolean value.
https://codeigniter.com/user_guide/datab...tml#insert

However, the function seems to return a database result object upon success. The source appears to confirm this: https://github.com/codeigniter4/CodeIgni....php#L2249

PHP Code:
$success $this->db->table('MyTable')
                    ->insert($dataTRUE);

if (
$success !== TRUE) {
  return FALSE;



Is this deviation between the documentation and the actual behavior intentional?
How can I check that the insert statement completed successfully? Can I be sure that the insert statement always returns false on failure?

I appreciate any input Smile

Controller can't return json data

$
0
0
Hello, I'm currently working with the PHP framework Codeigniter 4.0.4 and trying to add the PayPal Checkout Intergration with Smart Payment Buttons.

Console error:

Code:
Uncaught SyntaxError: Unexpected token < in JSON at position 0

Error: Unexpected token < in JSON at position 0
    at $t.error (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:59754)
    at Object.<anonymous> (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:67521)
    at JSON.parse (<anonymous>)
    at o (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:67380)
    at cr (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:67533)
    at Cr.u.on (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:72204)
    at Cr (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:72341)
    at https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:78460
    at Function.n.try (https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:14069)
    at https://www.paypal.com/sdk/js?client-id=Af6lu4xavdi1_e_hEFLWQxUj48hq0bndx7o3RGgwNWuChHmenioXFLMnTOKt912F6zmftF1Siv9WsfCp&disable-funding=credit,card:2:78257

Serverside:
PHP Code:
$clientId getenv('paypal.CLIENT_ID');
$clientSecret getenv('paypal.CLIENT_SECRET');

$environment = new SandboxEnvironment($clientId$clientSecret);
$client = new PayPalHttpClient($environment);

$request = new OrdersCreateRequest();
$request->prefer('return=representation');
$request->body = [
    "intent" => "CAPTURE",
    "purchase_units" => [[
        'reference_id' => '123',
        "amount" => [
            "value" => 10,
            "currency_code" => "USD"
        ]
    ]],
    "application_context" => [
        "cancel_url" => base_url() . "/checkout",
        "return_url" => base_url() . "/checkout"
    ]
];

try {
    $response $client->execute($request);
    return json_encode($response);
} catch (
HttpException $ex) {
    echo $ex->statusCode;
    print_r($ex->getMessage());



Clientside:
PHP Code:
<script type="text/javascript">
    paypal.Buttons({
        env'sandbox',

        style: {
            layout'vertical',
            size'responsive',
            shape'pill',
            color'blue',
            label'pay'
        },

        createOrder: function() {
            return fetch('/checkout/paypal', {
                method'post',
                headers: {
                    'content-type''application/json'
                }
            }).then(function(response) {
                return response.json();
            }).then(function(resJson) {
                return resJson.result.id;
            });
        }
    }).render('#paypal-button-container');
</
script

$response outputs the whole page I guess, how I can only return the $response json?

Call Ajax

$
0
0
hello.

I'm trying to make a post with ajax and I get the error 500, could someone help me

My Routes
PHP Code:
$routes->get('app-admin''\Modules\admin\Controllers\Auth::login');

 
$routes->get('app-admin/auth/authenticate''\Modules\admin\Controllers\Auth::authenticate');
 
$routes->get('app-admin/auth/recovery''\Modules\admin\Controllers\Auth::recovery');
 
$routes->get('app-admin/auth/logout''\Modules\admin\Controllers\Auth::logout');
 
$routes->get('app-admin/auth/update_password''\Modules\admin\Controllers\Auth::update_password'); 

My login.js
Code:
$(document).ready(function(){

    var APP_URL = $("#app_url").data("url");

    $("#login").validate({
        errorContainer: "#erroLogin",
        errorLabelContainer: "#erroLogin",
        wrapper: "p",
        errorElement: 'p',
        ignore: [],
        rules: {
            senha: "required",
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            senha: "Informe sua senha",
            email: {
                required: "Informe seu email",
                email: "Informe um email válido"
            }
        },
        submitHandler: function(form) {
            var submitTxt = $("#submitLogin").html();
            $("#submitLogin").html("Aguarde...");
            var request = $.ajax({
                url: APP_URL+"/auth/authenticate/",
                method: "POST",
                data: $(form).serialize(),
                cache: false,
                processData: false,
                dataType: "JSON"
            });
            request.done(function( msg ) {
                if(msg.status != 200){
                    div = '<div class="alert alert-warning alert-dismissable" style="margin-top:10px;">';
                    div += '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
                    div +=  msg.response;    
                    div += '</div>';
                    $("#submitLogin").html(submitTxt);
                    $( "#erroLogin" ).html( div ).css({'display': 'block'});
                }else{
                    $("#submitLogin").html( msg.response);
                    location.href= APP_URL+'/dashboard';
                }
            });
            request.fail(function( jqXHR, textStatus ) {
                $("#submitLogin").html(submitTxt);
                console.log( "Request failed: " + textStatus );
            });

            return false;
        }
    });

    
});

Login.php
PHP Code:
<?php echo view('\Modules\admin\Views\template\head'?>

<div class="flex-row align-items-center">


    <div class="container">
        <div class="row justify-content-center">
          <div class="col-md-5">
            <div class="card-group" style="margin-top: 20%;">
              <div class="card p-4">
                <div class="card-body">


                     <form id="login" method="POST" action="">
                      <h1>Login</h1>
                      <p class="text-muted">Olá, seja bem vindo.</p>
                      <div class="input-group mb-3">
                        <div class="input-group-prepend">
                          <span class="input-group-text"><i class="icon-user"></i></span>
                        </div>
                        <input type="email" class="form-control" id="email" name="email">
                      </div>
                      <div class="input-group mb-4">
                        <div class="input-group-prepend">
                          <span class="input-group-text"><i class="icon-lock"></i></span>
                        </div>
                        <input type="password" class="form-control" id="senha" name="senha">
                      </div>
                      <div class="row">
                        <div class="col-6">
                          <button type="submit" id="submitLogin" class="btn btn-primary px-4">Entrar</button>
                        </div>
                        <div class="col-6 text-right">
                          <a href="admin\recovery" class="btn btn-link px-0">Esqueceu a senha?</a>
                        </div>
                      </div>
                      </form>
                      <div id="erroLogin"></div>
                </div>
              </div>

            </div>
          </div>
        </div>
    </div>

    
</div>
<?php 
$js 
= array('/resource/admin/js/custom/login.js'); 
echo 
view('\Modules\admin\Views\template\footer', array('js'=>$js'login'=>true)); 
?>

My Controller

PHP Code:
public function login(){
        echo 
view('\Modules\admin\Views\auth\login');
    }


    public function 
authenticate(){


        if (
$this->request->isAJAX()) {
            
$prodID service('request')->getPost('id');
            
var_dump($this->request->getPost('id'));
        } 
        if(!
$this->input->is_ajax_request()){
            
$this->output("Forbidden"403);
        }

        
$email $this->input->post('email');
        
$senha $this->input->post('senha');

        
$email strtolower(trimstrip_tags$email ) ));
        if(!
filter_var($emailFILTER_VALIDATE_EMAIL)){
            
$this->output("O email informado é inválido."404);
        }            

        if(empty(
$senha)){
            
$this->output("Informe a senha."404);
        }

        
$user $this->_model->UserByEmailSenha$emailsha1($senha) );

        if(!
$user){
            
$this->output("Nenhum usuário encontrado para o email e senha informados."404);
        }

        if(
$user['ativo'] == 0){
            
$this->output("Sua conta se encontra desativada."404);
        }

        
$sessao = array(
            
'id'=> $user['id'],
            
'nome'=> $user['nome'],
            
'email'=> $user['email']
        );

        foreach (
$sessao as $key => $value) {
            
$this->session->set_userdata($key$value);
        }

        if(
$this->session->id){
            
$this->output("Redirecionando..."200);
        }else{
            
$this->output("Falha na autenticação. Tente novamente."404);
        }

    } 

And error:
Code:
jquery.min.js:4 POST http://localhost:8090/app-admin/auth/authenticate 500 (Internal Server Error)

The page does not open correctly:(

$
0
0
I have a page on codeignater 4. In the browser, the page opens correctly, but when I redirect to this page, the 404 page opens, and then if I refresh the page again, then it loads again correctly. Why could this be? 

also if I send a request to the page with ajax, then 404 opens, and it works correctly in the browser

My routes:
$routes->get('page2101', 'page::page2101');



My controller "Page"

public function page2101() {
echo 'Hello World!';
}

Captcha Helper

$
0
0
Hi

There is a captcha helper in CI3 but it doesn't exist in CI4 !
How should we implement captcha for forms?

XAMPP 7.4.11 Has Been Released


Comment request on NoSQL emulation

$
0
0
Hello everyone,

i've been cleaning up a little personnal project and released it on github.

It is a small and efficient schemaless CI component that acts  like an object oriented database.

It helps you store and manipulate Objects in db  without taking care of the underlying database design.

I used it with success in several personnal projects and i hope it may be useful to others.

It is the first time i release anything and it is still in dev state (for some parts) : constructive feedbacks and bug reports are more than welcome [Image: smile.png])

Have a great day

truong!!

The page does not open correctly:(

$
0
0
I have a page on codeignater 4. In the browser, the page opens correctly, but when I redirect to this page, the 404 page opens, and then if I refresh the page again, then it loads again correctly. Why could this be? 

also if I send a request to the page with ajax, then 404 opens, and it works correctly in the browser

My routes:
$routes->get('page2101', 'page::page2101');



My controller "Page"

public function page2101() {
echo 'Hello World!';
}

skilled developer wanted

$
0
0
Hello

I'm looking for someone who supports me in programming or takes over my part as a programmer, because I don't have the time to develop our system further myself.

It is based on CI3.1.11, runs on PHP7.4 on Apache or litespeed it is a part system of a big system, concretely a customer administration with linked services and products. We can also migrate to CI4, which I have never done due to time constraints.

I'm looking for a professional programmer with many years of experience who knows CI as an expert, a must is also strong JS knowledge. Good SQL knowledge is also important as many linked queries are executed via joins, these must run fast, 3 databases are used on 2 locations. External APIs are also used and requests must be made and evaluated via json. Another important point is the security, this must be as good as possible. Preferably someone who also brings in own ideas and thinks along. This is a long term employment, between 20%-100% everything is possible. Communication is done through a project management system, payment every week or every month, no matter the method.

Please report by PN with salary expectations and references.

Applicants can be tested with subtasks. Please no beginners, I do not have time to teach you programming. Please also no people who want to outsource the work to others.

Thanks

File upload

$
0
0
Hi there,


I'm using
PHP Code:
$file->move(WRITEPATH.'uploads'$fileName); 
to upload a file.

It's working but how to overwrite/replace the uploaded file with the same name?


Thank you

Using composer to install thirdparty library

$
0
0
Hi,
I am maybe asking "stupid" question but can someone help me with installing thirdparty library using composer.
First, I never used composer as I always install scripts manual (CI 4 is installed in manual way too). I know that it is used for installing and updating scripts but that is all.

So now I need to use https://github.com/ScoLib/cfscrape as part of my script is scraping data from other sources which sometimes are protected with Cloudflare DDoS protection.

 I have to run this command:
Code:
$ composer require cfscrape/cfscrape

But I don't know how and where. I guess that I have to login to my VPS via SSH and run it. Also have no idea where it would put files after running this command. Can it brake CI 4 folder structure or something. 

Any help is welcome.

Edit:
OK, I figure it out how to use composer: login to VPS and run "composer" command.
But is there anything that I should edit like config files or something to tell composer where to install libraries according to CI4 filder structure

How to use ZipArchive

$
0
0
Hi, I'm trying to use ZipArchive in my CI4 project. It is already enabled in my php but still give me error. Can someone tell me how to use this in CI4? Thank you.

.png   ziparchive.PNG (Size: 6.53 KB / Downloads: 0)

Upload Ci4 into the cPanel hosting problem

$
0
0
Hello,

1. I used cPanel shared hosting.
2. I uploaded all files in public folder into the public_html folder on my cPanel hosting.
3. I created a folder called ci_project before public_html and upload all other CodeIgniter files into ci_project folder.
4. I open index.php and change the $pathsPath = realpath(FCPATH . '../ci_project/app/Config/Paths.php');
5. After that, when I try to access my website I got bellow errors:

 
Warning: require(): Filename cannot be empty in /home/USERNAME/public_html/index.php on line 33
Warning: require(): Filename cannot be empty in /home/[b]USERNAME/public_html/index.php[/b] on line 33
Fatal error: require(): Failed opening required '' (include_path='.:/opt/cpanel/ea-php73/root/usr/share/pear') in /home/[b]USERNAME/public_html/index.php[/b] on line 33

Moving from Laravel

$
0
0
Hi,

I have been using Laravel up to this point, a small website with a blog, gallery and a few other elements I built.  I turned to Laravel as I wanted complete control over the way my site worked and nothing gave me exactly what I needed.  I am not a developer just someone who learnt PHP to get what I wanted.

My issue is that with every Laravel release (8 was just launched) it just seem to get more and more complex, introduces new 3rd party tools to learn. Although you can choose not to use, choosing not to appears to fight against the direction of the framework.

Like I say, not a developer and don't want to have to learn Laravel, mix, tailwind, npm, vue and so on just to keep my site running.

So I am looking for an alternative framework that keeps it far simpler.  CodeIgniter has been suggested although I have never used it.

Before I spend time on it I was wondering if some of you had views on the potential issues someone like me will have rebuilding in CI having come from Laravel?  

Thanks for any help. Heart

Codeigniter 4 Post Problem

$
0
0
I started use codeigniter 4 so new. Everything work properly on localhost but after insatalling on a host only "post" request not working. I cant get any valu after post request.
Html



Code:
<form  action="<?php echo base_url()."/slider/ekle" ?>" method="POST" enctype="multipart/form-data" >

        <div class="form-group">
          <label>Başlık</label>
          <input type="text" class="form-control"  placeholder="Slider başlığı" name="baslik" value=""/>
 
       </div>

      <div class="form-group mb-0">
         <div>
            <button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Ekle</button>
         </div>
      </div>
</form>
Ekle.php (Controller )
Code:
public function ekle()
    {

        $baslik=$this->request->getPost("baslik");
        $aciklama=$this->request->getPost("aciklama");

        print_r($baslik);
        die();
}
What i mean is everycodes are well working on "localhost" but "post" request not working on my host
After 

Code:
print_r($baslik); die();
 returning page is loading empty.


What could be the problem's sourche?

Codeigniter 4 Mysql

$
0
0
Gente buenas tardes!!!
Estoy teniendo el siguiente problema.

Estoy usando Codeigniter 4 el cual me deja insertar datos en la base de datos pero al momento de querer leer las tablas con el metodo find() siempre me devuelve un array vacio. Siendo que la tabla tiene varios registros.


Mi codigo es el siguiente

<?php namespace App\Controllers;
use App\Models\UserModel;

class Home extends BaseController
{
    public function index()
    {
        $userModel = new UserModel($db);
       
        $user = $userModel->findAll();
        var_dump($user);

       
        /* return view('welcome_message'); */
    }


}

"Headers already sent..." critical error

$
0
0
Anyone have a clue as to what would cause this?

Code:
CRITICAL - 2020-10-15 06:34:46 --> ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'ini_set(): Head...', '/opt/lampp/htdo...', 101, Array)
#1 /opt/lampp/htdocs/system/Session/Handlers/FileHandler.php(101): ini_set('session.save_pa...', '/opt/lampp/htdo...')
#2 /opt/lampp/htdocs/system/Config/Services.php(765): CodeIgniter\Session\Handlers\FileHandler->__construct(Object(Config\App), '172.17.21.46')
#3 /opt/lampp/htdocs/system/Config/BaseService.php(123): CodeIgniter\Config\Services::session(Object(Config\App), false)
#4 /opt/lampp/htdocs/system/Config/Services.php(754): CodeIgniter\Config\BaseService::getSharedInstance('session', NULL)
#5 /opt/lampp/htdocs/app/Controllers/Home.php(11): CodeIgniter\Config\Services::session()
#6 /opt/lampp/htdocs/system/CodeIgniter.php(882): App\Controllers\Home->__construct()
#7 /opt/lampp/htdocs/system/CodeIgniter.php(393): CodeIgniter\CodeIgniter->createController()
#8 /opt/lampp/htdocs/system/CodeIgniter.php(306): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#9 /opt/lampp/htdocs/public/index.php(45): CodeIgniter\CodeIgniter->run()
#10 {main}
CRITICAL - 2020-10-15 06:34:46 --> Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/app/Config/Events.php:27) in /opt/lampp/htdocs/system/Debug/Exceptions.php:161
Stack trace:
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', '/opt/lampp/htdo...', 161, Array)
#1 /opt/lampp/htdocs/system/Debug/Exceptions.php(161): header('HTTP/1.0 500 In...', true, 500)
#2 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException))
#3 {main}
  thrown
#0 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#1 {main}


My test server does not do this. Don't know why.

CI4 Project not working in Goddady VPS server

$
0
0
Hi,
I am new in codeigniter 4. I just complete a project with CI4 and it's very nicely working in localhost but when i upload online it's not working and getting following error which is make me trouble where i checked server requirements and all good with that.

Fatal error: Uncaught TypeError: Argument 1 passed to CodeIgniter\HTTP\URI:ConfusedetScheme() must be of the type string, null given, called in /home/hireexcellency/public_html/system/HTTP/IncomingRequest.php on line 615 and defined in /home/hireexcellency/public_html/system/HTTP/URI.php:665 Stack trace: #0 /home/hireexcellency/public_html/system/HTTP/IncomingRequest.php(615): CodeIgniter\HTTP\URI->setScheme(NULL) #1 /home/hireexcellency/public_html/system/HTTP/IncomingRequest.php(184): CodeIgniter\HTTP\IncomingRequest->detectURI('REQUEST_URI', 'hireexcellency....') #2 /home/hireexcellency/public_html/system/Config/Services.php(624): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\URI), '', Object(CodeIgniter\HTTP\UserAgent)) #3 /home/hireexcellency/public_html/system/Config/BaseService.php(123): CodeIgniter\Config\Services::request(Object(Config\App), false) #4 /home/hireexcellency/public_html/system/Config/Services.php(612): CodeIgniter\Config\BaseService::getSharedInstance('request', in /home/hireexcellency/public_html/system/HTTP/URI.php on line 665

if anyone know the solution kindly help me to solve the issue!

Note : If i uninstall "intl extension" from server then nothing showing in webpage!


Thank you
Viewing all 14353 articles
Browse latest View live


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