Location: PHPKode > projects > Helpdesk Over Web > how/sysmgmt/sites.php
<?php

// Site List Admin

// Include Configuration File
require_once ('../includes/config.inc'); 

// Set the page title and include the HTML header.
$page_title = 'Helpdesk Over Web - Sites Admin';
include ('../includes/header.html');

if (isset($_POST['sitename'])) { // Check if the form has been submitted.
	// Connect to Database
	require_once ('../includes/mysql_connect.php');

	if (empty($_POST['sitename'])) {
		$newdept = FALSE;
		echo '<H4><font color="red">ERROR - Site Name not Specified.</font></H4>';
		echo "<P>[ <A HREF='config.php'>Configuration Menu</A> ]</P>";
		include ('../includes/footer.html');
		mysql_close();		
		exit();
	} else {
		$newsite = $_POST['sitename'];
		$query = "INSERT INTO sites (SiteName) VALUES ('$newsite');";		
		$result = mysql_query($query)
		   or die("Invalid query: " . mysql_error());
		mysql_close();
		header ('Location: /how/sysmgmt/sites.php');	
		exit();
}
} 

// Connect to Database
require_once ('../includes/mysql_connect.php');

// Execute query to retrieve user details.
$sql = 'SELECT * FROM sites ORDER BY SiteName;';
$records = range(1, 500);
$result = mysql_query($sql)
   or die("Invalid query: " . mysql_error());
$num_rows = mysql_num_rows($result);

// Output query results in a table.
echo ("<H1>System Settings</H1><H3>Sites Database</H3>");
echo ("<TABLE WIDTH='600'><TR><TD WIDTH='175'><b>Site Name</b></TD><TD><b>Click to Delete</b></TD></TR>");
while($i = mysql_fetch_row($result)) { 
	echo ("<TR>");
	echo ("<TD>$i[1]</TD>");
	echo ("<TD><A HREF='deletesetting.php?type=site&id=$i[0]'>Delete</A></TD>");
	}
echo ("</TABLE>");
echo ("<H5>Add New Site</H5>");
echo "<FORM ACTION='sites.php' METHOD='post'><TABLE><TR><TD><b>Site Name</b>:</TD><TD><INPUT TYPE='text' LENGTH='52' MAXLENGTH='50' NAME='sitename'></TD></TR>";
echo "<TR><TD COLSPAN=2><input type='submit' name='submit' value='Add New Site' default></TD></TR></TABLE></FORM>";
echo "<P>[ <A HREF='config.php'>Configuration Menu</A> ]</P>";

// Include standard HTML footer
include ('../includes/footer.html');
mysql_close();
?>
Return current item: Helpdesk Over Web