blob: 85e77fbce4184757af46e526f2879adac668de84 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2006 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nathan Gervais (Eclipse Foundation)- initial API and implementation
*******************************************************************************/
#*****************************************************************************
#
# add_category.php
#
# Author: Nathan Gervais
# Date: Nov 3rd, 2006
#
# Description:
# This file adds a Category to the database
#****************************************************************************
require_once ("includes/header.php");
$id = $_GET['id'] ? $_GET['id'] : $_POST['id'];
$submit = $_GET['submit'] ? $_GET['submit'] : $_POST['submit'];
if ($submit == "Edit Category")
{
$catShortName = htmlentities($_GET['catShortName'] ? $_GET['catShortName'] : $_POST['catShortName']);
$description = htmlentities($_GET['description'] ? $_GET['description'] : $_POST['description']);
$query = "UPDATE categories set category_shortname = '$catShortName', description = '$description' where category_id = $id";
$result = mysql_query($query);
echo mysql_error();
?>
<html>
<body>
<h2>Category Edited Successfully</h2>
<a href="categories.php">Return to Categories</a>
</body>
<html>
<?
}
else
{
$query = "Select * from categories where category_id = $id";
$result = mysql_query($query);
echo mysql_error();
$dbiterator = mysql_fetch_array($result);
$catShortName = $dbiterator["category_shortname"];
$description = $dbiterator["description"];
?>
<html>
<body>
<h2>Edit a Category</h2><br/>
<form action="edit_category.php" method="POST">
<table>
<tr>
<td>Category Shortname :</td>
<td><input name="catShortName" value="<?=$catShortName;?>" type="text"></td>
</tr>
<tr>
<td>Long Description :</td>
<td>
<textarea name="description" rows="10" cols="50" wrap="off"><?=$description;?></textarea>
</td>
</tr>
<tr>
<td><input type="hidden" name="id" value="<?=$id;?>"></td>
<td><input type="submit" name="submit" value="Edit Category"/></td>
</tr>
</table>
</form>
</body>
<html>
<? } ?>