/feedback-form

This project helps to operate with feedback form, saving messages to DB

Primary LanguagePHP

Feedback form project

This form takes the users input data and place it to the Database.

File structure

index.php

This is the entry point of the application. It consists of html layout with feedback form inside.

core/DbConnector.php

  • Provides connection to Database via singleton pattern.
  • Parameters for connection stores in properties of the class DbConnector:
    • $host for host name,
    • $db_name for name of the Database,
    • $user for login,
    • $pass for password.
  • Main methods are:
    • getInstance() for class DbConnector,
    • getConnection() for PDO Object.

core/Model.php

  • This file store class Model to perform the operations with DB.
  • Main method is:
    • setFeedback() to insert new data to Database.

core/FormHandler.php

  • This method gets data from index.php by AJAX request in js/main.js and sets it to Database.
  • Parameters are:
    • $name for user's name,
    • $number for user's telephone number,
    • $email for user's email address,
    • $note for user's message,
    • $isClient to check if the user belongs to company's clients or not,
    • $gotData to mark if all the date was given with AJAX request.
  • Main methods are:
    • __construct() for setting values for properties of the class from POST request via AJAX,
    • setDataToDb() for setting data to Database by Model.php.

feedback.sql

This is the dump of the tables of my local feedback Database. It is partly filled for example.

Database structure

There is only one table named messages. It consists of columns:

  • id to store unique id of the certain feedback. This parameter is set to auto increment,
  • name to store user's name,
  • telephone to store user's telephone number,
  • email to store user's email address,
  • note to store user's message,
  • client to store mark if user is client of company or not.

css/bootstrap.min.css

Bootstrap file for html layout.

css/font-awesome.min.css

Font Awesome file for html layout.

css/main.css

Main stylesheet for custom style.

fonts/...

This directory stores fonts for project.

js/bootstrap.min.js

Bootstrap file for dynamic html layout.

js/jquery.validate.min.js

JQuery file for form validation.

js/jquery-3.1.0.min.js

JQuery file for dynamic layout and AJAX support.

js/main.js

JQuery file with custom functions:

  • for masked input of telephone number,
  • for AJAX request.

js/maskedinput.js

JQuery file for supporting of masked input.