Simple chat facility - if file exists not working |
We are trying to build a simple chat facility without using a database & have got the basic facility to work between 2 uses.
However, we want to first search to see if there is already a previous chat session in existence, but cant get that to work. This is what we have tried; PHP Code: <?php If the file does not exist then the Controller Files & View Files are created. That part works OK but needs further work. Can anybody guide us as to what we are doing wrong? UPDATE Ive got the system working but I need to learn how to get the scroll bar at the bottom. I want to get the scroll bar at the bottom when the page is opened, instead of the top by default. From my research CSS does not facilitate that. The following is my current coding; PHP Code: <style type="text/css"> .mem { position: fixed; width: 53%; left: 46%; top: 30%; font-family: arial; font-size: 100%; color: Black; bottom: 3.7%; overflow: auto; } </style> I would like a simple instruction like in the following, but that does not work; PHP Code: <style type="text/css"> .mem { position: fixed; width: 53%; left: 46%; top: 30%; font-family: arial; font-size: 100%; color: Black; bottom: 3.7%; overflow: auto; scrollToBottom; } </style> From my research it is only achievable by Javascript. Ive searched the following & acquired the coding below but they dont work; https://stackoverflow.com/questions/1861...scrolls-up PHP Code: var element = document.getElementById("yourDivID"); https://stackoverflow.com/questions/7063...-to-bottom The Javascript code below should keep your div's scrollbar positioned at the bottom like you described: PHP Code: var objDiv = document.getElementById("divExample");
It wont work because the whole application folder is using an .htaccess file
to stop viewing it. Look at the ,htaccess file. What you would need to do is move it all to the root folder were it is writable. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(06-22-2020, 03:57 AM)InsiteFX Wrote: It wont work because the whole application folder is using an .htaccess file Thanks InsiteFX. Obviously I need to learn more about .htaccess files. I have found 2. C:xampp/htdocs/application/.htaccess PHP Code: <IfModule authz_core_module> C:xampp/htdocs/.htaccess PHP Code: <IfModule mod_rewrite.c> I assume the root folder you speak of, is C:xampp/htdocs I need to keep the chat files separate from the many base files Ive created for the website proper. Is it wise to create chatterbox folders like C:xampp/htdocs/application/views/chatterbox/john/chris/chat & C:xampp/htdocs/application/controllers/Chatterbox/John/Chris/Chat and place a .htaccess file in the Chatterbox folder?
@christaliise: What exactly dosen't work? It dosen't find the file?
This are the correct way of building a path. PHP Code: APPPATH.'views'.DIRECTORY_SEPARATOR.'john'.DIRECTORY_SEPARATOR.'chris'.DIRECTORY_SEPARATOR.'chat'; redirect will however not work, unless you have a controller that's named chris.
(06-22-2020, 11:02 AM)jreklund Wrote: @christaliise: What exactly dosen't work? It dosen't find the file? Thanks jreklund. I want first a search for the file, if it is found, then redirect, to 'chris/john/chat' (keep in mind it is chris that is logged in) page where the previous conversations will be exposed. That does not work as it redirects whether or not the file exists. If the file is not found then it creates the 'chris/john/chat' & 'john/chris/chat' Controllers & view pages. The conversations can begin. That part I have working but it needs attention particularly in the variables for example. PHP Code: $lcuser = $this->session->userdata('user_name'); redirect is not a problem. Yes, I have Controllers for all the pages, for example Controllers for "Chris/Chat", "John/Chat", "Chris/John/Chat, & John/Chris/Chat. I dont understand your "correct way of building a path"? Can you explain? I guess by "DIRECTORY_SEPARATOR" you mean forward slash? [/]. But I notice your full stops & single quotes ['.]. When doing a fwrite I use double quotes, spaces & full stops [" . ].
This code:
APPPATH.'views'.DIRECTORY_SEPARATOR.'john'.DIRECTORY_SEPARATOR.'chris'.DIRECTORY_SEPARATOR.'chat'; Are the same as: "C:\xampp\htdocs\application\views\john\chris\chat" But it will work on all servers and operating systems. And if you ever move your folder, it will be found automatically, no need to change it manually every time. DIRECTORY_SEPARATOR will either generate / or \ depending of operating system. \ for Windows and / for Linux. At the moment you are missing one / (actually should be \), in case you want to hard-code it. Your code: "C:xampp/htdocs/application/views/john/chris/chat" Should be: "C:\xampp\htdocs\application\views\john\chris\chat"
If chat is the view file and not a folder you will need to add the .php extension also
when checking if the file exists. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(06-22-2020, 02:09 PM)jreklund Wrote: This code: Hi jreklund, do you know anything about Javascript. Ive updated my post wanting to know how to get the scroll bar at the bottom. Can you help?
(07-05-2020, 04:51 AM)jreklund Wrote: Hi, I'm afraid it too hard to see and answer without seeing it in real time. I dont know much about JSFiddle although I have been there. If you open many website pages including this one in this forum the scroll bar is at the top by default but because PHP does not facilitate the pasting of text part way into a page the only thing that can be done is to paste at the bottom when using fwrite. Therefore I want the scroll bar to be at the bottom when the page is opened, to avoid users having to scroll down each time they open the page. There are some sites that do that such as https://www.carousell.ph in their chat facility. That site obviously uses PHP. |
Welcome Guest, Not a member yet? Register Sign In |