To connect the database with PHP DOM page, do the following steps:
1. Create Database: Create a database using XAMPP, the name of database is “loginpage”. You can give any name to your database.
2. Create Table: Create table, inside “loginpage” database.
3. Create Table structure: Table should contain fields, according to your needs.
- id – primary key – auto increment
- name – varchar(100)
- password – varchar(100)
- How to pass form variables from one page to other page in PHP ?
- How to display search result of another page on same page using ajax in JSP?
- How to show Page Loading div until the page has finished loading?
- How to redirect a page to another page in HTML ?
- Create a database on Relational Database Service (RDS) of Amazon Web Services(AWS)
- Nodejs - Connect MongoDB with Node app using MongooseJS
- Nodejs – Connect Mysql with Node app
- How to connect multiple MySQL databases on a single webpage ?
- How to Display Flash Messages using connect-flash Module in Node.js ?
- How to connect Django with Reactjs ?
- Node.js socket.connect() Method
- PHP Program to count Page Views
- Refresh a page using PHP
- How to add API function to a simple PHP Page ?
- How to create admin login page using PHP ?
- How to minify HTML code of PHP page ?
- How to add a PHP page to WordPress?
- PHP program to fetch data from localhost server database using XAMPP
The datatype for name and password is varchar. The size can be alter as per the requirement. However, 100 is sufficient, and the datatype for “id” is int and it is a primary key. A primary key, also called a primary keyword, is a key in a relational database that is unique for each record. It is a unique identifier, such as a driver license number, telephone number (including area code), or vehicle identification number (VIN).
The structure of table will look like this
4. Insert values in the table:
After insertion, the table will look like this:
PHP Code: Create “connection.php” file. This is the connection code in PHP, to connect the database with any of your PHP DOM page.
Include the “connection.php” file inside the PHP DOM page.
After this, the database is connected with the PHP DOM page.