first php script with a purpose...
PAGE 1
<html>
<head>
<title>Welcome to Flite...</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<center>
<div class="installdiv">
<p class="title">Welcome To Flite...</p>
<br><br>
<form action="install2.php" method="post" name="dbaseq">
<p>Welcome to the Flite installation wizard. This will guide you through the installation of Flite in a quick and easy way. Lets get started; Please check below whether or not you have already set up a mySQL database in phpMyAdmin or another similar program... If you select no, one will be created for you with the name "flite".<br><br>
<input type="radio" name="dbaseq" value="yes"> Yes, I do have a database set up.<br>
<input type="radio" name="dbaseq" value="no"> No, I do not have a database set up.<br><br>
Please input your mySQL username and password below...<br><br>
<table>
<tr>
<td>
<p>Username:</p>
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
<p>Password:</p>
</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td>
<p>Password (confirmation):</p>
</td>
<td>
<input type="password" name="confirm">
</td>
</tr>
</table>
<center><input type="submit" value="Next" class="nextbutton"></center></p>
</form>
</div>
</center>
</body>
</html>
2ND PAGE
<html>
<head>
<title>Welcome to Flite...</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<center>
<div class="installdiv">
<p class="title">Welcome To Flite...</p>
<br><br>
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// If user answered yes, we'll go ahead and ask what that database name was... If the answere no, we will create the database and the table inside of it ////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function install($dbaseq, $username, $password) {
if ($dbaseq == "yes") {
?>
<p>Please enter the name of the database that you previously created and then click "Create Tables" which will poplulate the database.</p>
<form name="dbasename" action="install3.php" method="post">
<input type="hidden" name="username" value="<?php print("$username"); ?>"><input type="hidden" name="password" value="<?php print("$password"); ?>">
<p>Please enter the name of your database: <input type="text" name="dbasename"></p>
<center><input type="submit" value="Create Tables" class="nextbutton"></center>
</form>
<?php
} elseif ($dbaseq == "no") {
mysql_connect(localhost, $username, $password) or die(mysql_error());
mysql_create_db("flite") or die(mysql_error());
print("<p>mySQL database created succesfully.</p>");
mysql_close();
?>
<p>Please click "Create Tables" to populate database "Flite"</p>
<form name="dbasename" action="install3.php" method="post">
<input type="hidden" name="username" value="<?php print("$username"); ?>"><input type="hidden" name="password" value="<?php print("$password"); ?>">
<input type="hidden" name="dbasename" value="flite">
<center><input type="submit" value="Create Tables" class="nextbutton"></center>
</form>
<?php
}
}
///////////////////////////////////////////////////////////////////////
//// Call the install function, but first check if the passwords matched ////
///////////////////////////////////////////////////////////////////////
if ($password == $confirm) {
install($dbaseq, $username, $password);
} else {
print("<p>The password's didn't match... <a href=\"index.php\">Click Here</a> to go back</p>");
}
?>
</div>
</center>
</body>
</html>
3RD PAGE
<html>
<head>
<title>Welcome to Flite...</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<center>
<div class="installdiv">
<p class="title">Welcome To Flite...</p>
<br><br>
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Add the tables to the databse that either they created or we created on the last screen ////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function install($dbasename, $username, $password) {
mysql_connect(localhost, $username, $password) or die(mysql_error());
mysql_select_db($dbasename) or die(mysql_error());
mysql_query("CREATE TABLE flite_users(
id int(11) NOT NULL auto_increment,
username text NOT NULL,
password text NOT NULL,
email text NOT NULL,
access int(11) NOT NULL default '0',
PRIMARY KEY (id)
)
");
mysql_query("CREATE TABLE flite_forums(
id int(11) NOT NULL auto_increment,
title text NOT NULL,
PRIMARY KEY (id)
)
");
mysql_query("CREATE TABLE flite_posts(
id int(11) NOT NULL auto_increment,
title text NOT NULL,
created int(11) NOT NULL,
body text NOT NULL,
PRIMARY KEY (id)
)
");
print("<p>Tables created succesfully. <a href=\"..\">Click Here</a> to check out your new forum</p>");
mysql_close();
}
/////////////////////////
//// Call the Function ////
/////////////////////////
install($dbasename, $username, $password);
?>
</div>
</center>
</body>
</html>
My first...