Creating a Database Connection Page

Hello, this time let's create a page to access the database.
Database connection information is based on the basic information of MAMP.
Set the default connection information for your apm package program.
Basic connection information means user, password.
create folder myProject in htdocs

php image

and then create folder include in myProject

php image

^^ The source is as below.

htdocs/myProject/include/dbConnect.php

<?php
    $host = 'localhost';
    $user = 'root';
    $passWord = 'root'; //your password
    $dbName = 'myproject';

    $dbConnect = new mysqli($host, $user, $passWord, $dbName);

    if(mysqli_connect_errno()){
        echo "DB Connection Failed." . mysqli_connect_error();
    }
?>

atom

php image

result

php image

If you put host, user, password, and db's name in mysqli class, it will be connected to the db ^^.
So let's move on to the next class.