<?php
require('include/header.php');
$settingsid = $_GET['settings'];




if (isset($_POST['submit'])) {
?>	
<table class="table" width="100%" class="table">
	<tr class="table_header">
		<td>Change Settings</td>
	</tr>
	<tr class="row1">
		<td>
		<span class="genmed">
<?php
$sql = "UPDATE ".$prefix."settings SET pagename='$_POST[pagename]', slogan='$_POST[slogan]', email='$_POST[email]', script_url='$_POST[script_url]', template='$_POST[template]' WHERE id=".$settingsid;
if (!mysql_query($sql))
   {
   die('Error: ' . mysql_error());
   }
 echo "Your settings are edited succesfully in the database.";
?>
		</span></td>
	</tr>
</table>
<?php
}





$result = mysql_query("SELECT * FROM ".$prefix."settings WHERE id = ".$settingsid." ORDER BY id");
while($row = mysql_fetch_array($result)) {
$pagename = $row['pagename'];
$slogan = $row['slogan'];
$email = $row['email'];
$script_url = $row['script_url'];
$template = $row['template'];
?>



<form action="settings_edit.php?settings=<?php echo $settingsid; ?>" method="post">
<table class="table" border="0" width="100%">
	<tr class="table_header">
		<td colspan="2">Edit settings</td>
	</tr>
	<tr class="row1">
		<td width="140">
		Header Name: </td>
		<td>
		<br>
		<input name="pagename" size="20" value="<?php echo $pagename; ?>" /><br>&nbsp;</td>
	</tr>
	<tr class="row2">
		<td width="140">
		Slogan: </td>
		<td>
		<br>
		<input name="slogan" size="40" value="<?php echo $slogan; ?>" /><br>&nbsp;</td>
	</tr>
	<tr class="row1">
		<td width="140">
		<br>
		Your E-Mail<br>
&nbsp;</td>
		<td>
		<input name="email" size="30" value="<?php echo $email; ?>" /></td>
	</tr>



	<tr class="row2">
		<td width="140">
		<br>
		Script URL:<br>
&nbsp;</td>
		<td>
		<input name="script_url" size="50" value="<?php echo $script_url; ?>" /> Please end with a trailing slash '/'.</td>
	</tr>



	<tr class="row1">
		<td width="140">
		Template:</td>
		<td><br>
		<select size="5" name="template">
			<?php
				$directory = "../template/";
				$images = glob($directory . "*.css");
				foreach($images as $image)

				{
					$files = str_replace($directory, "", $image);
					echo "<option";

					if ($template == $files) 
						echo " selected";
					


					echo ">";
					echo $files;
					echo "</option>";
				}
			?>
		</select>
		<br><br></td>
	</tr>



	




	<tr class="row3">
		<td width="140">
		&nbsp;</td>
		<td>
 <br>
 <input type="submit" name="submit" value="Edit Settings" /><br>&nbsp;</td>
	</tr>
	</table>
</form>

<?php

}

require('include/footer.php');

?>
