Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
create database config file only if connected to db
Browse files Browse the repository at this point in the history
  • Loading branch information
devenbhooshan committed Jul 28, 2013
1 parent 900b84f commit 1fe1d71
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@
*/
require_once('functions.php');
if(isset($_POST['host'])) {
// create file 'dbinfo.php'
$fp = fopen('dbinfo.php','w');
$l1 = '$host="'.$_POST['host'].'";';
$l2 = '$user="'.$_POST['username'].'";';
$l3 = '$password="'.$_POST['password'].'";';
$l4 = '$database="'.$_POST['name'].'";';
$l5 = '$compilerhost="'.$_POST['chost'].'";';
$l6 = '$compilerport='.$_POST['cport'].';';
fwrite($fp, "<?php\n$l1\n$l2\n$l3\n$l4\n$l5\n$l6\n?>");
fclose($fp);
include('dbinfo.php');


// connect to the MySQL server
mysql_connect($host,$user,$password);
$link=mysql_connect($_POST['host'],$_POST['username'],$_POST['password']);
if (!$link) {
die('Could not connect:' );
}
else {
// create file 'dbinfo.php'
$fp = fopen('dbinfo.php','w');
$l1 = '$host="'.$_POST['host'].'";';
$l2 = '$user="'.$_POST['username'].'";';
$l3 = '$password="'.$_POST['password'].'";';
$l4 = '$database="'.$_POST['name'].'";';
$l5 = '$compilerhost="'.$_POST['chost'].'";';
$l6 = '$compilerport='.$_POST['cport'].';';
fwrite($fp, "<?php\n$l1\n$l2\n$l3\n$l4\n$l5\n$l6\n?>");
fclose($fp);
include('dbinfo.php');
// create the database
mysql_query("CREATE DATABASE $database");
mysql_select_db($database) or die('Error connecting to database.');
Expand Down Expand Up @@ -81,6 +87,7 @@
mysql_query($sql);
header("Location: install.php?installed=1");
}
}
?>
<!DOCTYPE html>
<html lang="en"><head>
Expand Down

0 comments on commit 1fe1d71

Please sign in to comment.