Welcome Guest, Not a member yet? Register   Sign In
No direct script access allowed
#1

hi,
I am converting my CI3 application to CI4.
I am facing this error
No direct script access allowed
I have included the following code, but it always, says
Code:
No direct script access allowed
defined('BASEPATH') OR exit('No direct script access allowed');
Here is controller:
Code:
<?php
namespace App\Controllers;
defined('BASEPATH') OR exit('No direct script access allowed');

// echo "This is home home home";
// die();

// http://www.2my4edge.com/2015/12/complete-basic-insert-view-edit-delete.html

use App\Models\MainModel;
use App\Models\Users_model;
use App\Models\login_database;

class Home extends BaseController
{
Reply
#2

(This post was last modified: 01-25-2023, 11:15 PM by kenjis.)

BASEPATH is not defined in CI4.
Remove the line "defined('BASEPATH') OR exit('No direct script access allowed');",
or define BASEPATH by yourself.
Reply
#3

(01-25-2023, 11:15 PM)kenjis Wrote: BASEPATH is not defined in CI4.
Remove the line "defined('BASEPATH') OR exit('No direct script access allowed');",
or define BASEPATH by yourself.

hi,

can you share some example? I am new, how can define it?
Reply
#4

I recommend you remove the line in all your files.
Because it is not necessary in CI4.

Add this in app/Config/Constants.php:
PHP Code:
define('BASEPATH''whatever'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB