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

Using on test server with IP address and username for URL

$
0
0
I'm moving my site to a new server. I restored the CPanel backup but I want to test the site before I change the domain to point to the new server. Until I like the domain I would load it using the IP/username, like: http://192.169.1.100/~myusername

Of course that breaks Codeigniter when I open http://192.169.1.100/~myusername/pagename

How can I get it working with the test server until I'm ready to point the domain over?

Changes are not visible on home page

$
0
0
Hello guys,
I'm new to CI and I have one heritable website. So the problem is that when I made changes they are not visible on home page or they start to be visible after a long period of time.

For example:
Let's say I change site_email in application/config/settings.php ( $config['site_email'] = "name@domain.com"; ) and it is visible on all of site pages except home. On the home page is still visible the old email address and maybe it's gonna change after a long time ago.

Can you help me with this if someone can suggest something that I can check?

Regards!

CodeIgniter Banner Font

$
0
0
The poll results are in, and the community has expressed a strong preference for the "Raleway" open source font, for use in the banner at the top of our forum and website.  You will see that shown there soon.

Thank you to the community members who participated in the poll. It had good participation.

Updating my Codeigniter to the latest version with gaps in between

$
0
0
My CI_Version is 3.1.5

It was downloaded last year and i worked a little bit on my project and stopped.

I'm starting it again this year and since i already updated my Bootstrap version on it. I might aswell update my Codeigniter version too. 

Anyways, current latest version of CI is 3.1.11 and i also visited the page on how to update CI version from previous versions but the example gave a version that was 'the previous version(3.1.10)' in my case, my current version(should be 5 versions in between if i'm to go by the version number) isn't the 'previous version' of the latest version.  

https://codeigniter.com/user_guide/insta..._3111.html

The only 3rd party libraries i used in my project are bootstrap and datatables. So it shouldn't be a hassle to upgrade.

Would it suffice for me to just copy over my controller/model/view and asset folder files to the current downloaded latest version of CI i have(3.1.11) and just update config/autoload/database files in config? 

Or can i follow the guide given by the link above and copy the files from 3.1.11 to my version 3.1.5? will it give me problems/errors?

A quick question: it says on the release topic of 3.1.11 that it has a new library called log library, can someone explain it's use exactly? can i use it to basically store logs(Action/history) for use in a notification/recommendation system?

First Impression: My day working with CodeIgniter 4.

$
0
0
I spent most of today working with CodeIgniter 4 instead of CodeIgniter 3 for the first and thought sharing my first impression with the community would be a nice way to finish up. 

Installation was a breeze and had no issues, I chose to clone from the GitHub repository (no particular reason for this choice other than it was the first method on the list). I already had the required PHP extensions installed.

LibCurl is required so I downloaded the source code and compiled, built and installed within a couple of minutes. 

Configuration was again very simple and similar to CodeIgniter 3, it has to be said though all this easiness is thanks to the quality of the documentation the CodeIgniter development team provide. One very nice feature is the separation of the applications base code and the 
publicly accessible document root, this is something I do as standard, but to see it used as the default configuration in something as popular as CodeIgniter is great progress for web security. I will never understand why anyone would put there admin folder or configuration files with passwords in the public web directory when there are simple ways to avoid it.

I have to be honest and say I found the changes in the layout a little frustrating to begin with and the odd little changes caught me out once or twice, for example the way the view method is used has changed from

PHP Code:
$this->load->view(); 

and now it is used as follows:

PHP Code:
echo view(); 

This seems simple but when you do something almost on autopilot for years you really have to stop and think. Other changes include the syntax of routes added and tiny little things like using a capital letter where you have never done before. but once you break habit the true genius of the new way starts to come to light. After working on version 4 for maybe 6 hours I switched back to version 3 and version 4 started to make so much sense.   

Some of the more important changes involve security and the improvements are more than welcome. I can now handle things in the CodeIgniter application that previously are handled all over the servers configuration. One of the things that interested me the most has to be the Restful server implementation and handling I have not got round to exploring this yet but having a way of making secure and correctly configured RESTul API's is long overdue.

I personally can not wait for the production ready version 4. I had a great day and I really enjoyed using it and now I have had a taste I will explore more the next time I have some free time. I recommend having a day out experimenting with what will be the future of PHP framework. 

I would love to read what you think if any of you have spent any real working with it.

Newbie question

$
0
0
Hi together,
I am new to codeigniter, but not new to php.
So I installed it, tried the first example from the tutorial, and it worked.

Now I walked through the second tutorial (that one with the news)
https://codeigniter.com/user_guide/tutor...ction.html

and at the end it says:
"Point your browser to your document root, followed by index.php/news and watch your news page."

But then I get a 404 error (produced by codeigniter).

Of course I controlled all files in the tutorial, but dont find the error.

How can I find out, where I made a mistake in the tuturial?
Is there somethink like a debug-modus?

Thanks in advance!
Marco

Searching multiple tables - fields

$
0
0
Hi there, 

I need the logic behind multiple field search. 

So far I have tried group_start() or_group_start() for nested search but did not have any proper result. 

Let me explain shortly what my problem is:
I have got 2 dropdown selects and 1 input. So, there must be 2 scenarios :

The first scenario - the search without input, which is for company name :

a) results based on city only (one of the selects) 
b) results based on category only (the other select) 
c) results based on city and category together

The second scenario - the search with input (name of company) :

a) results based on name only
b) only city
c) only category
d) city and category together
e) city and name match
f) category and name
e) all of them chosen together

I also tried creating multiple if, elseif on controller but it didn't seem so wise. I guess, It is only OK for 
if(empty($name)) { bla bla} // just to check an empty input I mean.

To sum up, Is trying group_start() correct? I need you to show me the route. Then I will try.

P.S : city, category and name are 3 different tables in my database.

Can't Redirect Well In Codeigniter 4

$
0
0
Hello My Pros,
How are you today please I am having issue to redirect to page.

I customise my app/Config/App.php by adding constructor to it where I auto set the base url like this

public function __construct()
{
$root = (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

$this->baseURL = $root;
}

I want to redirect to localhost/aensd/login
Where aensd is the folder where my application is stored
And It redirect to localhost/login instead of localhost/aensd/login calling error 404

if ($users->save($user))
{
// Success!

return redirect()->route('login')->with('message', lang('Auth.registerSuccess'));
}

please help me on this

Session Validation

$
0
0
I'm struggling to figure out how the session id validation should work. (CI version 3.1.11, PHP 7.2)

1. Nobble the cookie session value to some 32 character string in the browser
2. Submit the request

I would expect the submitted cookie value to be ignored i.e. a new session id to be generated as per use_strict_mode but this is not what happens.


Debug:
Session_driver php5_validate_id successfully detects the invalid id and the value of the cookie_name in the $_COOKIE array is unset.
Session_files_driver open function is then called with the user injected session id and subsequently opens a new session using that id.

What am I missing - perhaps I've misunderstood but I thought CI enforced use_strict_mode to prevent this?

Any help gratefully received. Security audit has failed us on this but I know the previous bug in this area was resolved in 3.1.9.

CSRF Cookie

$
0
0
Hello there,

I am new with CI4 and I am currently having problems accessing the CSRF cookie by javascript since the "httpOnly: true" header is currently being added which makes it impossible to obtain the value by methods such as Cookies.get('cookie-name') or others.
So, I wonder if there is any option to disable this header in this cookie?

Thanks in advance for the help Smile

Log.php Error

$
0
0
I got so many same notices;


Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined index: �NFO
Filename: core/Log.php
Line Number: 180
Backtrace:
File: /var/www/html/index.php
Line: 319
Function: require_once

I'm using the latest version.(3.1.11). The problem started after switching to version 3.1.11.

Help with Email Class

$
0
0
Hi, community!

This is my first topic.

I have a problem, I'm try to send a email for some users of my system that is based on CI 3.1.11 and the source html of the email is displayed. This is the configurations that I use at this moment:

$config['protocol']    = 'sendmail';
$config['mailpath']    = '/usr/sbin/sendmail';
$config['charset']    = 'utf-8';
$config['mailtype']    = 'html';
$config['wordwrap']    = TRUE;
$config['smtp_host']  = '****';
$config['smtp_user']  = '****';
$config['smtp_pass']  = '****';
$config['smtp_port']  = '25';
$config['smtp_crypto'] = 'tls';

Test message:
<center>
<table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="padding: 20px;" align="center" valign="top">
A
</td>
</tr>
<tr>
<td style="padding: 20px;" align="center" valign="top">
B
</td>
</tr>
</tbody>
</table>
</center>

But is displayed like it:
[Image: e9cc3f63ed.png]

How I can solve it? Thank you!

PHP errors now showing when running php 7

$
0
0
I have a local test server, WAMP. Codeigniter 3.1.10
When running PHP 5.6.40 PHP errors shows as expected.
But when I change to 7.0.33 or higher, no errors are shown. Even though the PHP.ini is set correctly with E_ALL and so on.

Anyone got a clue?

PHPUnit strangeness

$
0
0
I should start off by saying that I have PHPUnit working with the CI v4 dev repository. I've been using it successfully for a while and mostly know what I'm doing with it. But I ran into something very curious that I cannot explain and hope the hive-mind might have some insight or ideas. There's quite a lot of setup here so stick with me.

I'm looking into CodeIgniter\Log\Logger and it's associated "handlers" - the code behind this page of documentation.

I have a phpunit.xml that's used to control exactly which tests to run. It was created from phpunit.xml.dist that comes with the install and it looks like this.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/_support/_bootstrap.php"
        backupGlobals="false"
        colors="true"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        stopOnError="false"
        stopOnFailure="false"
        stopOnIncomplete="false"
        stopOnSkipped="false">
    <testsuites>
        <testsuite name="logs">
            <!--<directory>./tests/system/Log</directory>-->
            <file>./tests/system/Log/LoggerTest.php</file>
            <!--<file>./tests/system/Log/FileHandlerTest.php</file>-->
        </testsuite>

<!--not showing the rest because it's not relevant -->

The most relevant (to where I'm eventually going) section is

Code:
<testsuite name="logs">
    <!--<directory>./tests/system/Log</directory>-->
    <file>./tests/system/Log/LoggerTest.php</file>
    <!--<file>./tests/system/Log/FileHandlerTest.php</file>-->
 </testsuite>

Where I can run all or any of the logger tests by changing what is or is not commented. Executing PHPUnit with the xml file shown above will run only LoggerTest.php  resulting in a lovely green bar with the feel-good message of success for all tests in that test case.

I can use either of the following variations in the xml and get all green with both.

(runs all three tests in the directory)
Code:
<testsuite name="logs">
    <directory>./tests/system/Log</directory>
    <!--<file>./tests/system/Log/LoggerTest.php</file>-->
    <!--<file>./tests/system/Log/FileHandlerTest.php</file>-->
 </testsuite>

(runs only the two test files indicated)
Code:
<testsuite name="logs">
    <!--<directory>./tests/system/Log</directory>-->
    <file>./tests/system/Log/LoggerTest.php</file>
    <file>./tests/system/Log/FileHandlerTest.php</file>
 </testsuite>

The CLI command used is the same (where ./phpunit is a symbolic link to ./vendor/bin/phpunit)
Quote:./phpunit --testsuite logs

Finally, we get to the weird part.

If you run against only the one file ./tests/system/Log/FileHandlerTest.php or swap the order of the two files so FileHandlerTest.php comes first - all the FileHandlerTest tests fail. (There's only four of them.)

The problem seems to be due to autoloading because the message displayed is
Quote:Error: Class 'Tests\Support\Config\MockLogger' not found

Which happens on line 19 which is:
PHP Code:
$config = new LoggerConfig(); 

And, yes I believe the proper use statements are there. Look at the files yourself. This post is big enough without adding all that code. The unit test files are found in /your/folders/to/CodeIgniter4/tests/system/Log/

It gets even weirder though.

If you remove (or comment out) the setup() method of FileHandlerTest the first test succeeds but the rest fail due to undefined property errors. That makes sense because the properties were defined in the now missing setiup(). But wait a minute, where'd the "Class not found" error message go??? Apparently the class is found now.

I'm dumbfounded. (or maybe just dumb) What's going on?  Anybody?

CodeIgniter\Log and multiple handlers

$
0
0
I'm curious why CodeIgniter\Log::log() is designed such that if one handler returns false it won't continue with any other handlers in the queue?

It seems to me that it would be a good thing that if the (theoretical) EmailHandler failed to send an email that the FileHandler would still write to a log file.

submit button will do 2 things

$
0
0
this project is on 2.1.2 version
the existing apps will post/submit form and save the input to database...

now i want to make the button will do post the same data to another webservice at another host... what should i do?

how to know what's the detail data posted ... i've found the code related to the page on folder [CI_ROOTDIR]/application/controller/production.php... CMIIW

Note: i have set the print($data) but nothing printed on the page... any pointer will be appreciated

Fatal Errors when DataBase command fails

$
0
0
Hello all, I'm having a struggle with Fatal Errors being thrown when some of my Databases commands don't return successfully, for example:

Code:
$flag = true;
$db = \Config\Database::connect();
$builder_audio = $db->table('audios');

$data = [
'name' => $name,
'path' => $path
];

$builder_audio->insert($data);

if(!$db->affectedRows()){
$flag = false;
return $flag;
}

return $flag;

In my Database (Postgres) I created an UNIQUE KEY for the column "name". So when I try to insert a name that already exists I would like to get a return of none "affectedRows", and then deal with this return in my function, but when the error occurs, I get a Fatal Error, my request returns instantly with code 500 and an error description that follows:

Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse json string, error: &quot;Type is not supported&quot;. in /var/www/html/mysite/system/Format/Exceptions/FormatException.php:9

I could create an SELECT to search for the name before the INSERT, but I'm planning in creating some control in my database using UNIQUE KEYS for a better setup.

Thanks in advance

How to MYSQL conenct MYSQL cloud

$
0
0
Dear All Developer codeiqniter

I have plan build application used codeiqniter. but the problem i want try my application codeiqniter connect google mysql cloud or database in aws or digitalocean. different server

[Image: IFS.jpg]

you have tutorial how to codeiqniter connect mysql cloud maybe google cloud, aws cloud or digitalocean cloud but different server?

Thanks

EDIT: YOU DON'T HAVE TO SHOUT IN YOUR POST TITLES Undecided

Default permitted_uri_chars msg not showing up, instead showing exception error msg

$
0
0
I have a project made using CodeIgniter v 3.1.10. In the Config.php i have the default setting:


Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
Now, when I manually modify the url for e.g. as xyz.com/cat/'. Please note the apostrophe at the end of the URL, then I'm expecting the default error message like -

Code:
An Error Was Encountered
The URI you submitted has disallowed characters.
But instead of the above error message I'm getting an uncaught exception error message
[Image: YLoPu.jpg]
Can anyone please tell me what and where I need to change/Check. Thanks

How to prevent loading Controller without Route?

$
0
0
How to prevent loading Controller without Route?
Viewing all 14080 articles
Browse latest View live


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