<?php //************* MUST ALWAYS HAVE THIS ***********// require './txtSQL.class.php'; //*************DATABASE SETUP INFO*************// $db_username = ''; $db_password = ''; $database = 'carbon'; //**************PLACE THE DATABASE IS STORED***********// $sql = new txtSQL('./data/'); //***********CONNECT TO DATABASE****************// if (!$sql->db_exists($database)) { die("Please install Database -> <a href='./install.php'>Install DB</a>"); } $sql->connect($db_username, $db_password) or die('Unable to Connect To' . $database); //***********SLECET TO DATABASE****************// if (!$sql->selectdb($database)) { print $database . 'Could not be selected, check to make sure it exists'; }
<?php #Carbon2 Installer if (!$_POST) { echo "Please create a user now:\r\n\t\t<form action='install.php' method='post'>\r\n\t\tAdmin Username: <input type='text' name='admin_username'>\r\n\t\t<br />\r\n\t\tAdmin Password: <input type='password' name='admin_password'>\r\n\t\t<br />\r\n\t\tAdmin Password (again): <input type='password' name='admin_password2'>\r\n\t\t<br />\r\n\t\t<input type='submit' value='Start Install!'>\r\n\t\t</form>\r\n\t\t"; } elseif ($_POST) { if ($_POST['admin_password'] != $_POST['admin_password2']) { die("Error: Passwords don't match."); } include './txtSQL.class.php'; $db_username = "******"; $db_password = "******"; $database = "carbon"; //**************PLACE THE DATABASE IS STORED***********// $sql = new txtSQL('./data/'); //***********CONNECT TO DATABASE****************// $sql->connect($db_username, $db_password) or die('Unable to Connect To' . $database); //**********CREATE THE DATABASE**************// $sql->createdb(array('db' => $database)) or die('Error creating txtSQL DB, txtSQL said: ' . $sql->get_last_error()); //**********SELECT DATABASE TO USE**************// if (!$sql->selectdb($database)) { print $database . 'Could not be selected, check to make sure it exists'; } //****************CREATE TABLES IN DATABASE*****************// $nav = array('id' => array('type' => 'int', 'auto_increment' => 1), 'name' => array('type' => 'string'), 'page' => array('type' => 'string'), 'short_url' => array('type' => 'string'), 'order_id' => array('type' => 'int')); $sql->createtable(array('db' => $database, 'table' => 'nav', 'columns' => $nav)); /*******************************************/ $nav = array('name' => "News", 'page' => "index.php", 'short_url' => "news"); if (!$sql->insert(array('db' => $database, 'table' => 'nav', 'values' => $nav))) { die('An error occurred, txtSQL said: ' . $sql->get_last_error()); }