MLM(Multi Level Marketing) Website Using PHP - Binary Plan

Part 5 - Connect to Database

In this tutorial, we will create a connection to connect to the database. For this, we will create a database and will create tables and then we will create a connection code.

  • Create a Database with name mlm.
  • Then create a table user.
  • Create a page connect.php and save it within php-includes folder.
  • Now copy the code and past it to connect.php.
  • You can more understand in the video.




connect.php


Note - Connection strings may be different according to your server settings.

<?php
	$db_host = "localhost";
	$db_user = "root";
	$db_pass = "";
	$db_name = "mlm";
	
	$con =  mysqli_connect($db_host,$db_user,$db_pass,$db_name);
	if(mysqli_connect_error()){
		echo 'connect to database failed';
	}
?>                        


2481