CGI Interface BookLibrary
Table of Contents
- General info
- Technologies
- Site structure
- Setup
General-info
Goal:
Develop a C++ program that implements a CGI interface
Web server for creating and processing the database of library books.
My solution:
Using the capabilities of the sqlite3 library and the Apache server, I managed to write my own CGI interface in C ++ that provides the minimum functionality of a book library with the ability to add, delete, edit and search inside the database.
Technologies
- C++ 14
- sqlite (version: 3.40.0)
- cgicc (version: 3.2.19#5)
- xampp (implemented Apache server)
- To work with .db files used DB Browser SQLite
Site-structure
- MainPage.cpp - index.cgi file, main page with all information and from which all actions are performed. Have GET request to filter library searches by parameters for the title of the book and the name of the author.
URL: hostname/index.cgi
- AddToDB.cpp - AddToDB.cgi file, script gets data(book name, author, pages, etc...) from POST request and adds it to the database.
URL: hostname/cgi-bin/AddToDB.cgi
- DeleteFromDB.cpp - DeleteFromDB.cgi file, script gets data(in this case - id) from POST request, then searches element by id in the table and deletes it.
URL: hostname/cgi-bin/DeleteFromDB.cgi
- DropTable.cpp - DropTable.cgi file, script gets data(table name) from POST request, then drops table.
URL: hostname/cgi-bin/DropTable.cgi
- EditDB.cpp - EditDB.cgi file, script gets data(id) from POST request, then searches element by id in the table and sets up their values in the HTML FORM, then gives possibility to change this datas.
URL: hostname/cgi-bin/EditDB.cgi
- SaveEdit.cpp - SaveEdit.cgi file, script gets data(data from EditDB.cgi) then does UPDATE table with new data from EditDB.cgi.
URL: hostname/cgi-bin/SaveEdit.cgi
Setup
- Download xampp or use this files.
- Compile .cpp files into .cgi file and rename it like in Site structure.
- Move all .cgi file in cgi-bin folder like here.
- Use this config file to use Apache server.
- Start Apache server via xampp application.
- Write into your URL: localhost
Done! =)