Below code examine on how to integrate a popup/modal contact-form using Bootstrap and how to insert data into a database using PHP & MySQL. Basic bootstrap integrated html page code cast as below:
Adding popup/modal contact-form to the page:
To activate the visibility of popup/modal contact-form is can be linked by button below:
As mention above in previous code snippet, to complete the form need to add the below “php” code snippet inside of above code just after the end of <div class="row"> tag.
Once follow the above mention step by step guide Bootstrap integrated page interface cast as below:
Once click the button “Be Connected” or menu link “Contact” contact-form will pop-up while freezing the background page. The contact-form interface cast as below:
Step by step guide leads to finalize page code should cast as below:
Note: Even though this page written in “html” needed to save this as a .php (php extension) instead of .html (html extension), doing that will make run through the “php” code which written inside of this page.
Once finalize the popup contact-form page, need to create a database in “localhost –> phpMyAdmin”, first of all need to specify the “database name”, and then inside of that database import the following “sql” query.
-- phpMyAdmin SQL Dump-- version 5.0.2-- https://www.phpmyadmin.net/---- Host: 127.0.0.1-- Generation Time: Aug 11, 2020 at 12:54 AM-- Server version: 10.4.13-MariaDB-- PHP Version: 7.4.8SETSQL_MODE="NO_AUTO_VALUE_ON_ZERO";STARTTRANSACTION;SETtime_zone="+00:00";/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8mb4 */;---- Database: `dbnew`---- ------------------------------------------------------------ Table structure for table `contact`--CREATETABLE`contact`(`name`varchar(30)NOTNULL,`email`varchar(30)NOTNULL,`message`varchar(250)NOTNULL)ENGINE=InnoDBDEFAULTCHARSET=latin1;---- Dumping data for table `contact`--INSERTINTO`contact`(`name`,`email`,`message`)VALUES('roshan','roshan@xyz.abc','This is message one'),('perera','perera@xyz.abc','This is message two');COMMIT;/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Note: When creating the database specified “database name” & “database table name” is very crucial, moreover once accessing the database using “php” scripting language is addressed by “database name” & “database table name”.
Once finalize the database next step is to insert the data which we collect from “contact-form”. To do that need to write code snippet as below: