Location: PHPKode > projects > Silicon Fodder > SiliconFodder/DocumentRoot/notepad/editnote.php
<? require_once("../common/includes.php"); ?>
<? require_once("../admin/util.php"); ?>
<? require_once("../util/general.php"); ?>
<?
if($HTTP_POST_VARS["posted"] == "1") {
	if($HTTP_POST_VARS["folder"] == "" || $HTTP_POST_VARS["folder"] == "U") {
		$strSaveFolder = 0;
	} else {
		$strSaveFolder = $HTTP_POST_VARS["folder"];
	}

	$strNewNote = db_make_safe($HTTP_POST_VARS["newnote"]);

	if($strNewNote != "" && $HTTP_POST_VARS["id"] != "") {
		$strSQL = "UPDATE notepad SET note = '".$strNewNote."', notesort = '".substr($strNewNote,0,10)."', folderid = ".$strSaveFolder.", lastdate = NOW() WHERE id = ".$HTTP_POST_VARS["id"];
		gendb_query($strSQL, $myDb) or die(gendb_error());
	}

	header("Location: notepad.php?folder=".$HTTP_POST_VARS["folder"]);
	exit;
}
?>
<html>
<head>
<? require_once("../common/head.php"); ?>
<script language="javascript">
function submitForm() {
	document.frm.submit();
}
function changeFolder(folderid, foldername) {
	document.frm.folder.value=folderid;
	document.getElementById('foldertitle').innerHTML = foldername;
	parent.notepadFolders.location='folderSelect.php?folder='+folderid+'&nores=1';
}
function callPrint(title) {
	document.frmprint.strData.value=document.frm.newnote.value;

	document.frmprint.strTitleBar.value=title;
	document.frmprint.submit();
}
</script>
</head>
<?
$intNoteID = $HTTP_GET_VARS["id"];

$strSQL = "SELECT notepad.*, notepadfolders.foldername AS strFolderName FROM notepad LEFT OUTER JOIN notepadfolders ON notepad.folderid = notepadfolders.id WHERE notepad.id = ".$intNoteID;

$rows = gendb_query($strSQL, $myDb) or die(gendb_error());
$row = gendb_fetch_assoc($rows);

$strNote = $row["note"];
$strSelectedFolder = $row["folderid"];

if($strSelectedFolder == "0") {
	$strFolderName = "Unfiled";
	$strSelectedFolder = "U";
} else {
	$strFolderName = $row["strFolderName"];
}

gendb_free_result($rows);
?>
<body>
<?
if(isPda()) {
	$buttons = displaySaveButton("savenote", "submitForm();");
	$buttons.= "&nbsp;".displayCancelButton("cancelnote", "history.go(-1);");
	pdaHeader("Notepad", "", true, $buttons);
} else {
	$buttons = displaySaveButton("savenote", "parent.showNoteUnloadMsg=false;submitForm();");
	$buttons.= "&nbsp;".displayCancelButton("cancelnote", "parent.showNoteUnloadMsg=false;document.location.href='notepad.php?folder=".$strSelectedFolder."';");
	dispHeader("Notepad");
}
?>
<?=displayErrorMessage()?>
<form name="frm" method="post" action="editnote.php">
<input type="hidden" name="folder" value="<?=$strSelectedFolder?>">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="id" value="<?=$intNoteID?>">

<? if(!isPda()) { ?>
<table width="100%" cellspacing="0" cellpadding="1">
<tr>
<td>
<table width="100%">
<tr><td align="left"><?=$buttons?></td>
<td align="right"><a href="#" onClick="javascript:callPrint('Note folder: <?=eregi_replace("'","\\'",$strFolderName)?>');"><img src="/images/print1.gif" border="0" alt="Print Friendly Popup"></a></td>
</tr>
</table>
</td>
</tr>
</table>
<hr>
<? } ?>
<table width="100%">
<tr>
<td class="titlebar">
Edit Note :
<span id="foldertitle">
<?= $strFolderName ?>
</span>
</td>
</tr>
<tr>
<td>
Notes:<br>
<? if(isPda()) { ?>
<textarea name="newnote" cols="40" rows="6"><?=$strNote?></textarea>
<? } else { ?>
<textarea onChange="parent.showNoteUnloadMsg=true;" name="newnote" rows="15" style="width:100%;height:300px"><?=$strNote?></textarea>
<? } ?>
</td>
</tr>
</table>
<?=dispFooter()?>
<script language="javascript">
if(parent.notepadFolders && parent.notepadFolders.location.toString().indexOf('folderSelect.php') <0) {
parent.notepadFolders.location='folderSelect.php?folder=<?=$strSelectedFolder?>&nores=1&type=edit';
}
</script>
</form>
<form name="frmprint" method="post" action="printnote.php" target="_blank">
<input type="hidden" name="strHeader" value="Notepad">
<input type="hidden" name="strTitleBar" value="Note">
<input type="hidden" name="strData">
</form>
</body>
</html>
<? require_once("../common/incFinal.php"); ?>
Return current item: Silicon Fodder