<?php
require('../config.php');
mysql_connect("$host", "$username", "$password")or die("cannot connect to the database."); 
mysql_select_db("$db_name")or die("cannot select the database.");

$installed = 0;
?>

<html>

<head>
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>My Link Trader - Setup</title>
<link href="../template/basic.css" rel="stylesheet" type="text/css" />
</head>

<body>


<div align="center">
<table class="table">
	<tr class="table_header">
		<td colspan="2">Setup - Database settings</td>
	</tr>
	<tr class="row1">
		<td width="150">Hostname:</td>
		<td width="150"><b><?php echo $host; ?></b></td>
	</tr>
	<tr class="row1">
		<td width="150">DB Username:</td>
		<td width="150"><b><?php echo $username; ?></b></td>
	</tr>
	<tr class="row1">
		<td width="150">DB Password:</td>
		<td width="150"><b>********</b></td>
	</tr>
	<tr class="row1">
		<td width="150">DB Name:</td>
		<td width="150"><b><?php echo $db_name; ?></b></td>
	</tr>
	<tr class="row1">
		<td width="150">DB Prefix:</td>
		<td width="150"><b><?php echo $prefix; ?></b></td>
	</tr>
	<tr class="row1">
		<td width="300" colspan="2">
			<br><p align="center">

				<?php
				$result = mysql_query("SELECT * FROM ".$prefix."settings WHERE id = 1");
				while($row = mysql_fetch_array($result)) {
					//$installed = $row['installed'];
					if ($row['installed'] == 1) {
						echo "<b>My Link Trader already exist with prefix: <br><u>".$prefix."</u><br><br>
						Please choose a other prefix.</b>";
						exit;
					}
				}
						echo "<center><b>Connection with the database is made.<br>We can install My Link Trader.</b></center>";
				?>
				</td>
	</tr>

	<tr class="row1">
		<td width="300" colspan="2">
		<form method='post' action='index.php'>
			<p align="center">&nbsp;</p>
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<tr class="row1">
					<td>Website Name:</td>
					<td>
			<input type="text" name="pagename" size="20" value="My Link Trader"></td>
				</tr>
				<tr>
					<td>Your E-Mail:</td>
					<td>
			<input type="text" name="email" size="20" value="your@email.com"></td>
				</tr>
				<tr>
					<td colspan="2">
					<p align="center"><br>
					<input type='submit' name='submit' value='Install Starting Page'></td>
				</tr>
			</table>
		</form>
		</td>
	</tr>

	<tr class="row3">
		<td width="300" colspan="2"><b>
			<?php
				if(isset($_POST['submit']))
				{
					include ('sql.php');
					echo "<center><br>My Link Trader is installed correctly.<br><br>";
					echo "You can now go to the:<br>";
					echo "<a href='../admin/index.php'>Admin Panel</a><br>";
					echo "Username = admin<br>Password = password<br><br>";
					echo "<a href='../index.php'>My Link Trader</a><br><br><br>";
					echo "Please delete the 'install' folder for security reasons.</center>";
				}
			?>
		</b></td>
	</tr>
</table>
</div>



<?php

?>