CodeIgniter Forums

Full Version: Does folder exist
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I want to create a simple search if a "folder" exists. If it doesn't I want a notification similar to form_validation error.

I've developed the coding below, the 1st line works but the 2nd line doesn't work.

PHP Code:
if(!is_dir("members/$boss"))
$this->form_error("$boss"'The boss username does not exist'); 

I want an error notification output - The boss username does not exist'

But if the folder does exist then the process continues.

I've searched many sites however some come close but not precisely what I want.

Can anybody guide me?
I think what you need is this library.

CodeIgniter Message Library

It has not been updated but should still work.
(08-28-2019, 03:49 AM)InsiteFX Wrote: [ -> ]I think what you need is this library.

CodeIgniter Message Library

It has not been updated but should still work.

Thanks InsiteFX, Ive downloaded that library and installed it into both "system/libraries" and "application/libraries" but I get An Error Was Encountered Unable to load the requested class: Messages

I have changed the coding to 1 line as follows;

PHP Code:
if(!file_exists("members/$boss")) die ("UsernameDoesntExist"); 

It works but the notification appears on a blank page.

If I insert the following into the view page I get the text box and the notification, but without the submit button and again on a blank page.

PHP Code:
<?php die ("UsernameDoesntExist"); ?>

The same applies if I replace "die" with "exit".

I understand this is because "die" & "exit" terminates the PHP scripting.

I have tried "echo", "print", "goto", "return" & a few others but they don't work.

The above probably could be fixed if I could get the message library to work.
Did you autoload the library like in their config file?

The library uses sessions for the messages.

You may need to use Ajax to post the messages to the html web pages.
(08-28-2019, 07:53 AM)InsiteFX Wrote: [ -> ]Did you autoload the library like in their config file?

The library uses sessions for the messages.

You may need to use Ajax to post the messages to the html web pages.

I just downloaded, copied & pasted, obviously that is not right, but I don't know how to autoload.
To autoload ./application/config/autoload.php

Add it to the libraries array.

Here is another one I found that uses flash messages.

CodeIgniter Message
(08-28-2019, 08:27 AM)InsiteFX Wrote: [ -> ]To autoload ./application/config/autoload.php

Add it to the libraries array.

Here is another one I found that uses flash messages.

CodeIgniter Message

OK, but how do I apply the autoload to the unzipped folder?

I've inserted the following and both give - An Error Was Encountered Unable to load the requested class: Messages;

$this->load->library('messages');
$this->load->library(array('form_validation', 'messages'));
You need to unzip the file that you downloaded.

./application/config/autoload.php

PHP Code:
// Load the messages library
$autoload['libraries'] = array(
    
'messages'
); 
(08-28-2019, 10:37 AM)InsiteFX Wrote: [ -> ]You need to unzip the file that you downloaded.

./application/config/autoload.php

PHP Code:
// Load the messages library
$autoload['libraries'] = array(
    'messages'
); 

Yes, I've unzipped both the files, copied & pasted them into application/libraries folder (I also pasted the first one into system/libraries folder) that is leaving the folder names the same - codeigniter-message-library-master & codeigniter-message-master

And I already had existing in ./application/config/autoload.php

PHP Code:
$autoload['libraries'] = array(); 

so I added 'messages' but it made no difference.
Are you auto loading the session library also?

PHP Code:
// Load the messages library
$autoload['libraries'] = array(
    'session',
    'messages',
); 

You need to be running the session library because that is what the message library is using.
Pages: 1 2