THIS IS THE FUNCTIONS FILE
<?php
function pf_script_with_get($script) {
$page = $script;
$page = $page . "?";
foreach($_GET as $key => $val) {
$page = $page . $key . "=" . $val . "&";
}
return substr($page, 0, strlen($page)-1);
}
?>
<?php
session_start();
require("Config.php");
require("Functions.php");
//Determine if the user is logged in and can access this page:
require("Functions.php");
if (isset ($_SESSION['ADMIN'])==FALSE) {
header("Location:Index.php");
}
//Process the form:
if ($_POST['submit']) {
$catsql = "INSERT INTO categories VALUES ('" . $_POST['category'] . "')";
$catresult = mysql_query($catsql);
header("Location:Index.php");
}
else {
require("Header.php");
}
?>
SECOND FILE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Category</title>
<h3>Add a new Category</h3>
</head>
<body>
<form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>" method="post">
<table width="200" border="1">
<tr>
<td>Category</td>
<td><input type="text" name="category"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Add Category"></td>
</tr>
</table>
</form>
</body>
</html>