Location: PHPKode > projects > DataDivisions > includes/funcEditDisplay.php
<?
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# DataDivisions, Build 1.0, 12/11/2003                                      #
# FileName: funcEditDisplay.php                                             #
# File Description:                                                         #
#   Provides functions required for a user to edit a saved display (back-   #
#   end, middle and front-end)                                              #
#                                                                           #
# +-----------------------------------------------------------------------+ #
# | DataDivisions - Website Statistic Visualization Software              | #
# | Copyright (c) 2003, Brian Willison                                    | #
# +-----------------------------------------------------------------------+ #
# | The contents of this file are subject to the GNU General Public       | #
# | License version 2 (June 1991). This file and all its contents (incl.  | #
# | functions, methods, etc.) are free for general use within any         | #
# | community. This software is distributed with the intent to allow      | #
# | developers the opportunity to copy, manipulate and revamp this        | #
# | application in part or whole for best use cases.                      | #
# |                                                                       | #
# | This software is distributed "AS-IS" with no warranties of any kind   | #
# | either expressed or implied.                                          | #
# |                                                                       | #
# | Please refer to the GPL license document for more information:        | #
# | (_docs/gplLicense.pdf)                                                | #
# +-----------------------------------------------------------------------+ #
# | Developer, Designer, Initial Creator:                                 | #
# | Brian Willison (hide@address.com)                       | #
# +-----------------------------------------------------------------------+ #
# | Initial Download Reference:                                           | #
# | http://datadivisions.sourceforge.net                                  | #
# +-----------------------------------------------------------------------+ #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

// Function: Check Register Form
function checkEditDisplayForm($_POST) {
	if ($_POST['desc'] == "") {
		return "blankSubmit";
	} else {
		// Gather Posted Data
		$username = $_POST['username'];
		$displayUrl = $_POST['displayUrl'];
		$desc = stripslashes($_POST['desc']);
		// Connnect To Db To Update Description Of Saved Display
		$dbOpen = dbConnect();
		$query = "UPDATE ".dbTableSavedDisplays." SET description='$desc' WHERE username='$username' AND displayUrl='$displayUrl'";
		$result = mysql_query($query) or die(mysql_error());
		dbClose($dbOpen);
	}
}
// Function: Generate Register Form
function genEditDisplayForm($errorCheck) {
global $_POST,$_GET;
	$username = (isset($_GET['username'])) ? $_GET['username'] : $_POST['username'];
	$displayUrl = (isset($_GET['displayUrl'])) ? $_GET['displayUrl'] : $_POST['displayUrl'];
	$displayUrl = ereg_replace("\(","",$displayUrl);
	$displayUrl = ereg_replace("\)","",$displayUrl);
	$displayUrl = ereg_replace("_","&",$displayUrl);
	// Get Existing Description From Db
	$dbOpen = dbConnect();
	$query = "SELECT * FROM ".dbTableSavedDisplays." WHERE username='".$username."' AND displayUrl='".$displayUrl."'";
	$result = mysql_query($query) or die(mysql_error());
	$resultArray = mysql_fetch_array($result);
	$origDisplayDesc = $resultArray[1];
	dbClose($dbOpen);
	genAppSmHeader(pageName);
?>
	<tr>
	<td></td>
	<td valign="top" colspan="3"><p class="header">To edit your description of this display, please alter its description in the form below. 
	When you are finished, please click "Submit."</td>
	</td>
	</tr>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,10);?></td>
	</tr>
<?
	if ($errorCheck != 0) {
		printf("\t<tr><td></td><td valign=\"top\" colspan=\"3\"><p class=\"error\">%s</td><td></td></tr>",genErrorMsg($errorCheck));
	}
?>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,10);?></td>
	</tr>
	<tr>
	<form name="emailDisplay" method="post" action="<?=phpSelf?>">
	<td></td>
	<td valign="top"><p align="right">Description:</td>
	<td></td>
	<td><p><textarea name="desc" cols="22" rows="3"><?if(isset($origDisplayDesc))echo$origDisplayDesc;elseif(isset($_POST['desc'])){echo$_POST['desc'];}?></textarea></td>
	<td></td>
	</tr>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,10);?></td>
	</tr>
	<input type="hidden" name="username" value="<?=$username?>">
	<input type="hidden" name="displayUrl" value="<?=$displayUrl?>">
	<tr>
	<td></td>
	<td></td>
	<td></td>
	<td valign="top"><input type="submit" name="submit" value="Submit" class="btnSubmit"></td>
	<td></td>
	</form>
	</tr>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,15);?></td>
	</tr>
<?
	genAppSmFooter(pageName);
}
?>
Return current item: DataDivisions