renamed db parameters because of user form

This commit is contained in:
HB9HIL
2024-01-28 01:59:20 +01:00
parent 057c0518a3
commit ccf0c710e1
2 changed files with 11 additions and 11 deletions

View File

@@ -9,19 +9,19 @@ class Core {
$counter = 0;
// Validate the hostname
if(isset($data['hostname']) AND !empty($data['hostname'])) {
if(isset($data['db_hostname']) AND !empty($data['db_hostname'])) {
$counter++;
}
// Validate the username
if(isset($data['username']) AND !empty($data['username'])) {
if(isset($data['db_username']) AND !empty($data['db_username'])) {
$counter++;
}
// Validate the password
if(isset($data['password']) AND !empty($data['password'])) {
if(isset($data['db_password']) AND !empty($data['db_password'])) {
// pass
}
// Validate the database
if(isset($data['database']) AND !empty($data['database'])) {
if(isset($data['db_name']) AND !empty($data['db_name'])) {
$counter++;
}
@@ -61,10 +61,10 @@ class Core {
// Open the file
$database_file = file_get_contents($template_path);
$new = str_replace("%HOSTNAME%",$data['hostname'],$database_file);
$new = str_replace("%USERNAME%",$data['username'],$new);
$new = str_replace("%PASSWORD%",$data['password'],$new);
$new = str_replace("%DATABASE%",$data['database'],$new);
$new = str_replace("%HOSTNAME%",$data['db_hostname'],$database_file);
$new = str_replace("%USERNAME%",$data['db_username'],$new);
$new = str_replace("%PASSWORD%",$data['db_password'],$new);
$new = str_replace("%DATABASE%",$data['db_name'],$new);
// Write the new database.php file
$handle = fopen($output_path,'w+');

View File

@@ -6,14 +6,14 @@ class Database {
function create_database($data)
{
// Connect to the database
$mysqli = new mysqli($data['hostname'],$data['username'],$data['password'],'');
$mysqli = new mysqli($data['db_hostname'],$data['db_username'],$data['db_password'],'');
// Check for errors
if(mysqli_connect_errno())
return false;
// Create the prepared statement
$mysqli->query("CREATE DATABASE IF NOT EXISTS ".$data['database']);
$mysqli->query("CREATE DATABASE IF NOT EXISTS ".$data['db_name']);
// Close the connection
$mysqli->close();
@@ -25,7 +25,7 @@ class Database {
function create_tables($data)
{
// Connect to the database
$mysqli = new mysqli($data['hostname'],$data['username'],$data['password'],$data['database']);
$mysqli = new mysqli($data['db_hostname'],$data['db_username'],$data['db_password'],$data['db_name']);
// Check for errors
if(mysqli_connect_errno())