Location: PHPKode > projects > Butterfly Organizer > addedit.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/Edit Account Details</h2>';

$mytable = $_GET['mytable'];
$id = $_GET['id'];
$currentDate = date("F j, Y, g:i a");

if(isset($_POST['update'])) {

	$id = $_POST['id'];
	$date = $_POST['date'];
	$reference = $_POST['reference'];
	$name = $_POST['name'];
	$url = $_POST['url'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$notes = $_POST['notes'];
	$other = $_POST['other'];

	$sql = "UPDATE ".$mytable." SET id='$id',date='$date',reference='$reference',name='$name',url='$url',username='$username',password='$password',notes='$notes',other='$other',lastmodified='$currentDate' WHERE id=$id";
	$result = mysql_query($sql);
	redirect();
}
else if($id) {
	$result = mysql_query("SELECT * FROM ".$mytable." WHERE id=$id",$database);
	$myrow = mysql_fetch_array($result);
	?>
	<form method="post" action="addedit.php?id=<?php echo $myrow['id']?>&amp;mytable=<?php echo $mytable;?>">
	<input type="hidden" name="id" value="<?php echo $myrow['id'];?>" />
	<input type="hidden" name="lm" value="<?php echo $currentDate;?>" />
	<table cellspacing="1" cellpadding="2" class="mainTable">
		<tr><td class="td_title">ID:</td><td class="td_content"><input type="text" name="id" value="<?php echo $myrow["id"]?>" /></td></tr>
		<tr><td class="td_title">Date:</td><td class="td_content"><input type="text" name="date" value="<?php echo $myrow["date"]?>" /></td></tr>
		<tr><td class="td_title">Reference:</td><td class="td_content"><input type="text" name="reference" value="<?php echo $myrow["reference"]?>" /></td></tr>
		<tr><td class="td_title">Name:</td><td class="td_content"><input type="text" name="name" value="<?php echo $myrow["name"]?>" /></td></tr>
		<tr><td class="td_title">URL Address:</td><td class="td_content"><input type="text" name="url" value="<?php echo $myrow["url"]?>" /></td></tr>
		<tr><td class="td_title">Username:</td><td class="td_content"><input type="text" name="username" value="<?php echo $myrow["username"]?>" /></td></tr>
		<tr><td class="td_title">Password:</td><td class="td_content"><input type="text" name="password" value="<?php echo $myrow["password"]?>" /></td></tr>
		<tr><td class="td_title">Notes:</td><td class="td_content"><textarea class="expanding" name="notes"><?php echo $myrow["notes"]?></textarea></td></tr>
		<tr><td class="td_title">Other:</td><td class="td_content"><textarea class="expanding" name="other"><?php echo $myrow["other"]?></textarea></td></tr>
	</table>
	<div class="menubar"><input type="submit" name="update" value="Update" class="bsButton" /></div>
    </form>
	<?php
}
else {}

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