Location: PHPKode > projects > Butterfly Organizer > category-create.php
<?php
/*
Butterfly Organizer
Copyright (C) 2007-2008 Butterfly Media Romania

This file is part of Butterfly Organizer.

Butterfly Organizer 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

include('includes/top.php');

echo '<h2>Add New Site Category</h2>';

//$submit = $_POST['submit'];

if(isset($_POST['submit'])) {
	$newsite = $_POST['newsite'];
	$newsite = str_replace(' ','_',$newsite);
	$tabela=$newsite;
	$sql_1_command='SELECT * FROM '.$tabela;
	$query_1=mysql_query($sql_1_command, $database);
	if($query_1!=true) {
		$sql_2_command="CREATE TABLE `".$tabela."` (`id` int(11) NOT NULL auto_increment,`date` text NOT NULL,`reference` text NOT NULL,`name` text NOT NULL,`url` text NOT NULL,`username` text NOT NULL,`password` text NOT NULL,`notes` text NOT NULL,`other` text NOT NULL,`lastmodified` text NOT NULL,PRIMARY KEY (`id`)) TYPE=MyISAM";
		$query_2=mysql_query($sql_2_command, $database);
	}
	redirect();
}
else {
	echo '<form method="post" action="category-create.php">';
	echo "Category name: <input type='text' name='newsite' />";
	echo '&nbsp;<strong>(example: Butterfly Media Romania, Trafic_Ro)</strong><br /><br />Characters allowed: letters, digits, underscores and spaces;<br />Name must not begin with a digit.<br /><br />';
	echo '<div class="menubar"><input type="submit" name="submit" value="Add Category" class="bsButton" /></div>';
	echo '</form>';
}

include('includes/bottom.php');
?>
Return current item: Butterfly Organizer