Dynamic status update without database interaction Dynamic status update without database interaction codeigniter codeigniter

Dynamic status update without database interaction


There is 1 solutions for this:

  1. Send and receive information using AJAX from and to server wich has installed software with API

I think this is what you want to do.


Feel free to correct my understanding of the issue, but here's how I see this at the moment.

  1. You have a web site that has multi stage forms. So user fills the first one, then sends it, and gets the next one to be filled.
  2. You also have a web server, probably running PHP, that handles user interaction. So whenever user fills a form, your server application proceeds with that and gives the user the next one.
  3. Furthermore, there are multiple external servers and services that your PHP application gives orders to based on the information given by the user.
  4. You will want to show process information from external services whenever things do proceed.
  5. Finally, you don't want to use a oh so heavy database solution if a lighter one exists.

If I have gotten the facts about right so far, there may be a suitable solution to help you out.

To begin with, it's worth mentioning that PHP has its own session mechanism. Its data storage defaults to flat files, which may or may not be suitable for your use. Yet it requires almost no configuration or setup and offers a persistent storage, so it's by far the easiest option, in my opinion.

Note, that if the amount of information to be stored is very small, you can bypass the application data storage altogether and stick to the cookies. Read on form submit, update during the PHP process and send update the cookie accordingly as part of the response. You can encrypt the data in order to make it harder to alter by the user.

Lastly, there's this option called cache. There are multiple technologies for this when working on PHP. For instance: xcache and APC. These store information in RAM, which obviously has its downsize, since data can basically vanish at any given time - you can control this, though.

No matter the choice of data storage, the general idea is as follows:

  • When user first interacts with your service, create a session identifier and an approriate cookie to identify the user later on.
  • When user has filled the first form and sends it, read the information and either store it in the cache or in the cookie. When storing and reading information from and to the cache, either prefix or namespace it using the session identifier used by user. This way there can be multiple users using the service at any given time! When done, send the second form to be filled.
  • When user eventually sends the second form, read from the cache or from the cookie the information given to the first one. Now, should the information be missing, there has been an error in the filling process (or cache has been invalidated due to long time period or cookie expiration time - you will want to take these things into account, too).
  • So long things are going nicely, build up your information gathered from the forms. Whenever you have enough information to do so, make a request to the external service to really make things happen.
  • Now, lastly. You can do periodical ajax requests from the client. Therefore you get not only the forms sent, but also occasional "how is the process going?" queries. Now, whenever you receive a request like that from the browser, you can identify the user by session identifier and make a call from your PHP application to your external service, asking for a status of any kind. You then simply forward the information to the browser that has been waiting the answer all this time.

Note that you may have to store service spesific information in your cache to do this.

This setup, however, effectively gives you the ability to control data flow in your PHP application without revealing the services behind it. It's also lightweight enough to develop as it requires no additional external software for short term data storage.