I am using VMWARE and done install LAMP server on it. I've create two UBUNTU vm's. One is for system and another one is for database. The insert database in PHP program system should insert in another vm which is specifically for database. I've already make a connection between two vm's using SSH and grant privileges method.
VM 1= For PHP system, VM 2= For database that PHP data should insert.
This is signup system. I've already created database name as 'authentication' and table as 'users' with name and password in the table.
<?php
session_start();
$db = mysqli_connect("192.168.117.129","root","abc","authentication"); //ip for vm2
if (isset($_POST['signup_btn'])) {
$name = mysql_real_escape_string($_POST['name']);
$password = mysql_real_escape_string($_POST['password']);
$rePassword = mysql_real_escape_string($_POST['rePassword']);
if ($password == $rePassword) {
$password = md5($rePassword);
$sql = "INSERT INTO users(name, password) VALUES('$name', '$password')";
mysqli_query($db,$sql);
$_SESSION['name'] = $name;
header("location: login.php");
exit;
}else{
$_SESSION['message'] = "The two passwords do not match";
}
}?>
The problem is, when I insert the data in the system, it's unable to connect with mysql database. What should I do?