All pastes #71757 Raw Edit

Something

public text v1 · immutable
#71757 ·published 2006-06-26 03:12 UTC
rendered paste body
<?php 
if (isset($_POST['add']))
{
	$error; 
	$num = 0;
	
	if($_POST['name'] == "")
	{
		$error .= "The <em>Name</em> field must be filled out.<br />";
		$num++;
	}
	if($_POST['category'] == "")
	{
		$error .= "The <em>Category</em> field must be filled out.<br />";
		$num++;
	}
	if($_POST['short'] == "")
	{
		$error .= "The <em>Short Description</em> field must be filled out.<br />";
		$num++;
	}
	if($_POST['full'] == "")
	{
		$error .= "The <em>Full Description</em> field must be filled out.<br />";
		$num++;
	}
	if($_POST['image'] == "")
	{
		$error .= "The <em>Image</em> field must be filled out.<br />";
		$num++;
	}
	if($_POST['price'] == "")
	{
		$error .= "The <em>Price</em> field must be filled out.<br />";
		$num++;
	}
	if($num != 0)
	{
		echo "<p id=\"error\">$error</p>";
	}
	
	if($num == 0) // If no errors
	{
		if($_POST['available'] == "available")  // If the item is available
		{
			$available = 1;
			echo "checked";
		}
		else
		{
			$available = 0;
		}

		$query = "
		INSERT INTO 'items' ( 'name' , 'category' , 'short' , 'full' , 'image' , 'price' , 'available' )
		VALUES (
			'".$_POST['name']."', 
			'".$_POST['category']."', 
			'".$_POST['short']."', 
			'".$_POST['full']."', 
			'".$_POST['image']."', 
			'".$_POST['price']."', 
			'".$available."'
		)
		";
		
		if(mysql_query($query))
		{
			echo "The item has been added to the store.";
		}
		else
		{
			echo "<p id=\"error\">There has been an error.</p>";	
		}

	}
		
}
else 
{
?>