The Application Guidelines

Modern application developing for most common cases quick guide.

Step by step. Starting from building database backend, PHP connection API to native and Web frontends you gain systematized knowledge plus important clues to create an application using tools and IDEs. I. First step is to organize processed data in a database tables. Collect all the information you will process using developed system. Clue might be analyzing all the information routes in a company that are repetitive in a phone calls or document exchange. Structuralize this data in form of SQL tables, maintaining relations to prepare the database backend for your system and application.

I. IMPLEMENTATION: The best OpenSource solution to apply your data structure is advanced method with PHPMyAdmin and manual tables creation or LibreOffice with MySQL plugin using graphical relations editor. II. Second step is to organize all the information flows using API written in server side scripting language like PHP. Idea is not to link program directly to MySQL as it’s not secure, but open precisely predefined routes to add, modify, read or process data in database using POST an GET HTTP methods.

II. IMPLEMENTATION: As mentioned preferred OpenSource server side scripting language is PHP on a LAMP equipped server. Use text editor like to write scripts. Few code snippets you probably want to use:

MySQL connection and query example: $link = mysqli_connect($sql, $sqluser, $sqlpass,$sqldb); mysqli_set_charset($link,'utf8'); $result = mysqli_query($link,'SELECT * FROM `users`;');

POST and GET method’s variables and SESSION for managing cookies:

session_start(); $_SESSION['argument']=$newsessionvar; $getvar = $_GET['argument']; $postvar = $_POST['argument'];

Serialization of data arrays: $array = unserialize($_POST['argument']); echo serialize($array); III. Next you’ll build a Web frontend for users outside company to access or only view the data processing results. Obviously languages to achieve that are HTML and JavaScript. Good enhancement for JavaScript in such case is commonly used jQuery.

III. IMPLEMENTATION: Tool for writing code is again Geany. In most cases you will use HTML forms including files submission. Also often preferred way is to use AJAX queries to dynamically load content without refreshing a page.

Form HTML example allowing sending files to PHP script with placeholders:

AJAX content load in any container like

with jQuery:

$('#container').load('http://site.com/script.php?arg=' . $value); IV. The last step is to create native window based application for more comfortable access to data resources. Using a programming language like ++ or you can access a PHP API with POST and GET queries.

IV. IMPLEMENTATION: You can use Free Pascal integrated IDE or Creator C++ integrated IDE to design forms and code them quickly. In Lazarus you’ll probably want to install “weblaz” package to allow POST/GET queries and you may find JSON useful to process your data/information.

Lazarus example of simple query communication with API:

Result := FPHTTPClient1.SimpleGet('http://site.com/script.php?arg=' + val);

Qt Creator example of simple query communication with API:

QNetworkRequest request('http://site.com/script.php?arg=' + val); QNetworkAccessManager manager; QNetworkReply *reply = manager.get(request); while(!reply->isFinished()) { qApp->processEvents(); }