![]() |
Does folder exist - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Does folder exist (/showthread.php?tid=74213) Pages:
1
2
|
Does folder exist - christaliise - 08-27-2019 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")) 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? RE: Does folder exist - InsiteFX - 08-28-2019 I think what you need is this library. CodeIgniter Message Library It has not been updated but should still work. RE: Does folder exist - christaliise - 08-28-2019 (08-28-2019, 03:49 AM)InsiteFX Wrote: I think what you need is this library. 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. RE: Does folder exist - InsiteFX - 08-28-2019 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. RE: Does folder exist - christaliise - 08-28-2019 (08-28-2019, 07:53 AM)InsiteFX Wrote: Did you autoload the library like in their config file? I just downloaded, copied & pasted, obviously that is not right, but I don't know how to autoload. RE: Does folder exist - InsiteFX - 08-28-2019 To autoload ./application/config/autoload.php Add it to the libraries array. Here is another one I found that uses flash messages. CodeIgniter Message RE: Does folder exist - christaliise - 08-28-2019 (08-28-2019, 08:27 AM)InsiteFX Wrote: To autoload ./application/config/autoload.php 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')); RE: Does folder exist - InsiteFX - 08-28-2019 You need to unzip the file that you downloaded. ./application/config/autoload.php PHP Code: // Load the messages library RE: Does folder exist - christaliise - 08-28-2019 (08-28-2019, 10:37 AM)InsiteFX Wrote: You need to unzip the file that you downloaded. 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. RE: Does folder exist - InsiteFX - 08-29-2019 Are you auto loading the session library also? PHP Code: // Load the messages library You need to be running the session library because that is what the message library is using. |