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)
- Create a database on Relational Database Service (RDS) of Amazon Web Services(AWS)
- How to display search result of another page on same page using ajax in JSP?
- How to pass form variables from one page to other page in PHP ?
- How to redirect a page to another page in HTML ?
- How to show Page Loading div until the page has finished loading?
- How to connect Django with Reactjs ?
- Nodejs – Connect Mysql with Node app
- Node.js socket.connect() Method
- Nodejs - Connect MongoDB with Node app using MongooseJS
- How to connect multiple MySQL databases on a single webpage ?
- How to Display Flash Messages using connect-flash Module in Node.js ?
- CSS | @page rule
- How to add a PHP page to WordPress?
- ES6 | Page Redirect
- ES6 | Page Printing
- Refresh a page using PHP
- How to get the title of an HTML page ?
- CSS page-break-before Property
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.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.