Location: PHPKode > projects > PLiMa > plima-0.5.2/lib/addremove.php
<?
/***
	*   pLiMa - php List Manager
  *   Copyright (C) 2003  Jinn Koriech (hide@address.com)
	*
  *		This file is part of pLiMa.
	*
	*   pLiMa 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; either version 2 of the License, or
	*   any later version.
	*
	*   pLiMa 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 pLiMa; if not, visit http://www.gnu.org or write to the 
	*   Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
	*	  Boston, MA  02111-1307  USA
	*	
	*/
	require("../inc/init.inc.php");
	
	// Get the list of columns to be populated
	foreach ( $_POST AS $key => $val ) {
		if ( $key != 'list_name' && $key != 'action' ) {
			$columns[] = $key;
			$values[] = addslashes($val);
		}
	}
	
	if ( $_POST['action'] == 'add' ) {
		$cols = substr(@implode(", ", $columns), 0, strlen(@implode(", ", $columns)) );
		$vals = substr(@implode("', '", $values), 0, strlen(@implode("', '", $values)) );
		$sql = "REPLACE INTO ".TABLE_PREFIX.$_POST['list_name']." ( $cols ) VALUES ( '$vals' )";
	} elseif ( $_POST['action'] == 'remove' ) {
		$sql = "DELETE FROM ".TABLE_PREFIX.$_POST['list_name']." WHERE email = '{$_POST['email']}'";
	}
	
	db_query($sql);
?>
<form action='/lib/addremove.php' method='post'>
	<input type='hidden' name='list_name' value='test' />
	<select name='action'>
		<option value='add'>Add me!</option>
		<option value='remove'>Remove me!</option>
	</select>
	<input type='text' name='email' />
	<input type='text' name='name' />
	<input type='text' name='country' />
	<input type='submit' value=' Go ' />
</form>

Return current item: PLiMa