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

// Useful Links List Admin

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

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

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

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

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

// Execute query to retrieve user details.
$sql = 'SELECT * FROM usefullinks ORDER BY Title;';
$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>Useful Links Database</H3>");
echo ("<TABLE WIDTH='600'><TR><TD WIDTH='175'><b>Title</b></TD><TD><b>Click to Delete</b></TD></TR>");
while($i = mysql_fetch_row($result)) { 
	echo ("<TR>");
	echo ("<TD><A HREF='$i[1]' TARGET='_new'>$i[2]</A></TD>");
	echo ("<TD><A HREF='deletesetting.php?type=link&id=$i[0]'>Delete</A></TD>");
	}
echo ("</TABLE>");
echo ("<H5>Add New Link</H5>");
echo "<FORM ACTION='usefullinks.php' METHOD='post'><TABLE WIDTH=500><TR><TD><b>URL</b>:</TD><TD><INPUT TYPE='text' LENGTH='152' MAXLENGTH='150' NAME='usefullink'></TD></TR>";
echo "<TR><TD><b>Title</b>:</TD><TD><INPUT TYPE='text' LENGTH='62' MAXLENGTH='60' NAME='title'></TD></TR>";
echo "<TR><TD COLSPAN=2><input type='submit' name='submit' value='Add New Type' 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