0

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>&nbsp;</td>
    <td><input type="submit" name="submit" value="Add Category"></td>
  </tr>
</table>
</form>




</body>
</html>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by chrishea
0

Welcome to Daniweb.

Someone added code tags for you so your code is (now) more understandable. The problem is that you didn't state your specific problem or provide any supporting info as to what you have already tried and what it is supposed to do. If you want someone to help you, then you need to show that you are making some effort and trying to make it easy for us to understand the problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.