$value) { if(!$value && $key != 'db_pass') { echo '

'.$key.' is required

';; die; } } echo '

Trying to connect to database '.$_POST["db_name"].'

'; //try to connect to server $connect = connect($_POST["db_host"], $_POST["db_user"], $_POST["db_pass"], $_POST["db_name"]); if($connect) { echo '

Connection successful.

'; } else { echo '

ERROR! Connection unsuccessful.

'; die; } //make sure the db exissts $db_exists = mysql_select_db($_POST["db_name"], $connect); if($db_exists) { echo '

Database exists.

'; } else { echo '

ERROR! Could not select database.

'; die; } //make sure tables do not exist $tables = select("SHOW TABLES"); //tables I want are PREFIX.images //PREFIXvotes foreach($tables as $table) { if($table["Tables_in_".$_POST["db_name"]] == $_POST["table_prefix"].'images') { echo '

ERROR! Tables already exist. Exiting.

'; die; } elseif($table["Tables_in_".$_POST["db_name"]] == $_POST["table_prefix"].'votes') { echo '

ERROR! Tables already exist. Exiting.

'; die; } } echo '

Creating tables...

'; include("build-db.php"); echo '

Writing config file...'; $cfile = file_get_contents('../config.inc.php'); if(strlen($ccfile) > 0) { echo ' ERROR! Config file exists.

'; } include("write-config.php"); echo ' done.

'; echo '

Installation finished. Redirecting to home page in ... 5 seconds

'; echo ''; ?>