Welcome Guest, Not a member yet? Register   Sign In
Does folder exist
#1

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?
Reply
#2

I think what you need is this library.

CodeIgniter Message Library

It has not been updated but should still work.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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.
Reply
#4

(This post was last modified: 08-28-2019, 07:55 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(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.
Reply
#6

To autoload ./application/config/autoload.php

Add it to the libraries array.

Here is another one I found that uses flash messages.

CodeIgniter Message
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(This post was last modified: 08-28-2019, 09:35 AM by christaliise. Edit Reason: Explain what I've tried. )

(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'));
Reply
#8

You need to unzip the file that you downloaded.

./application/config/autoload.php

PHP Code:
// Load the messages library
$autoload['libraries'] = array(
    
'messages'
); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(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.
Reply
#10

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB