Location: PHPKode > projects > Grocery List > addGLItem.php
<?php
########################################################################
#
# Project: Grocery List
# URL: http://sourceforge.net/projects/grocery-list/
#
# Copyright: (C) 2007, James Campbell
# License: GNU General Public License Version 3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Filename: $URL: https://grocery-list.svn.sourceforge.net/svnroot/grocery-list/releases/1.0/addGLItem.php $
# Last Updated: $Date: 2010-03-06 00:03:07 -0800 (Sat, 06 Mar 2010) $
# Author(s): James Campbell
#
########################################################################

$title = 'Add Item';
include_once("include/site.php");

$Quantity = isset($_GET["Quantity"]) ? $_GET["Quantity"]: "";
$Name = isset($_GET["Name"]) ? $_GET["Name"] : "";
$mfctr = isset($_GET["mfctr"]) ? $_GET["mfctr"] : "";
$Notes = isset($_GET["Notes"]) ? $_GET["Notes"] : "";
$units = isset($_GET["units"]) ? $_GET["units"] : "";
$Size = isset($_GET["Size"]) ? $_GET["Size"] : "";

//echo "quantity = $Quantity, Name = $Name, mfctr = $mfctr, size = $Size, units = $units, Notes = $Notes<br>";




if($Quantity == NULL)
{
$Quantity = 1;
}




$decname = urldecode($Name);
$decmfctr = urldecode($mfctr);
$decnotes = urldecode($Notes);

if($Size == NULL)
{
	$sql = "insert into groceries (quantity, itemname, units, manufacturer, notes) values ($Quantity, \"$decname\", \"$units\", \"$decmfctr\", \"$decnotes\")";
}
else
{
	$sql = "insert into groceries (quantity, itemname, size, units, manufacturer, notes) values ($Quantity, \"$decname\", $Size, \"$units\", \"$decmfctr\", \"$decnotes\")";
}

//echo "sql = $sql<br>";

$connection = dbconnect();
//$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");
$sql_result = $connection->query($sql);

//mysql_free_result($sql_result);
//mysql_close($connection);
$connection = NULL;

if ($sql_result)
{
	$loc = "GroceryList.php";
	header("Location: $loc");
	exit;
}

include_once($WEBROOT . "/include/footer.php");

?>
Return current item: Grocery List