Installing My Database

← General Stuff — Started 22 Apr, 2011

c3f3 Admin
22 Apr, 2011, 8:38 am (This post was last modified: 22 Apr, 2011 8:39 am by c3f3 Admin.)
Ok, so i thought i might aswell make a new thread for this, because over the next day or 2 depending on how long this will take me, i will be makeing my own install so that i can configure my database easily, and that if any of my friends needs my login system, then they can install it easily... I am having problems when looking at how MyBB has done it, because it is all in OOP, and i dont really understand that to be honest, so i am making 1 from scratch...

So far, i have my dbconfig.php:
PHP Code:
<?php
$dbname 
'dbname';
$dbuname 'dbuname';
$dbpwd 'dbpwd';
$host 'localhost';
?>

And my install/index.php (which i am currently working on at the moment).
PHP Code:
<html>
<
head>
<
title>Installing 'users' Database...</title>
</
head>
<
body>
<?
php

if(isset($_GET['step']))
{
 
$step $_GET['step'];
}
else
{
  
$step 0;
}

switch(
$step)
case 
0;
?>

<p>Welcome to the Cyb3r Fr3aks installer...</p>

<?php
break;
case 
1:
?>

<form action="?step=1" method="post">
<input type="text" name="dbname" />
<input type="text" name="dbuname" />
<input type="password" name="dbpwd" />
<input type="text" name="host" value="localhost" />
<input type="submit" name="submit" value="Next" />
</form>

<?php
break;
case 
2:

$dbname trim($_POST['dbname']);
$dbuname trim($_POST['dbuname']);
$dbpwd trim($_POST['dbpwd']);
$host trim($_POST['host']);

if(
$_POST['submit'] && !empty($dbname,$dbuname,$dbpwd,$host)
{
  require 
"../dbconfig.php";
  
$replace =
  
  
</
body>
</
html

The current problem im having is that i dont know how i can look-up my variables stored in dbconfig.php, and then replace them with the new ones that the user input through my form...
[Image: 1_15_01_11_6_52_28.png]
Well, you can do require_once on dbconfig.php, and you'll be able to use the variables in it. For writing files, you need to take a look at a combination of fopen and fwrite - http://php.net/manual/en/function.fwrite.php

User(s) browsing this thread: 2 Guest(s)