Location: PHPKode > projects > MyPHPBib > bib_addnote.php
<?php

require_once ('login/user.inc.php');
//$user->MembersOnly(); // this will check if user can access page, and bounce them if not
include ('phpbib/phpbib.inc.php');

?>

<?php include ('header.inc.php'); ?>

<body>

<?php include ('top.inc.php'); ?>
<?php $user->MembersOnly(); ?>
 <div id="content"> 

<?php
	if (($_SERVER['REQUEST_METHOD']!='POST'))
	{
		// Populate form with this reference
		$ref_id 	= $_GET['id'];
		$r = new Reference();

    if ( ereg ( "MSIE" , $_SERVER['HTTP_USER_AGENT'] ))
    {
            echo "<script language=\"JavaScript1.2\">\n";
    }
    else
    {
                echo "<script language=\"JavaScript1.2\" type=\"application/x-javascript\">\n";
    }
    


?>

    function validateNotesForm(form) 
    {  
        if (form.notes.value == "") 
        { 
                alert("Please enter some notes."); 
                form.notes.focus(); 
                return false; 
        }
else
{
	return true;
}
}
</script> 




<form name="form1" method="post" action="" onsubmit="return validateNotesForm(this)">
<input name="id" type="hidden" id="id" value="<?php echo $ref_id; ?>"/>
<table cellpadding="4" border="0" cellspacing="0" width="100%">

<tr><td><?php echo $r->GetFormattedReference($ref_id, 'simple'); ?></td></tr> 

<tr><td>Your notes:</td></tr>
    <tr>
      <td><textarea name="notes" id="notes" cols="60" rows="10"></textarea></td>
    </tr>

    <tr>
      <td><input type="submit" name="Submit" value="Add note"/></td>
    </tr>
</table>



</form>


<?php



	}
	else
	{

		
//echo "Reference id = ", $_POST['id'], "<br/>";
//echo "User id = ", $user->GetUserId(), "<br/>";

$allowedTags='<a><br><i><img><li><ol><p><strong><table><tr><th><td><u><ul>';

$notes = strip_tags($_POST['notes'],$allowedTags); 

//echo $notes;

$r = new Reference();
$r->AddNote($_POST['id'],  $user->GetUserId(), $notes);

echo "Note added to database<br/><a href=\"bib_display_reference.php?id=", $_POST['id'], "&amp;format=report\">Back to record</a><br/>"; 


/*		// Store updated details in the database 
		// (called if user submits edit form), then
		// redirect back to display form
		$r = new Reference();
		$r->Populate($_POST);
		$r->Update();
		$html = "<script language=\"JavaScript\">";
		$html .= "alert(\"Reference has been updated in the database\");";
		$html .= "document.location = 'bib_display_reference.php?id=";
		$html .= $_POST['reference_id'];
		$html .= "&format=report';";
		
		$html .= "</script>";
		echo $html;
*/
	}
?>


 </div>

<?php include ('footer.inc.php'); ?>


</body>
</html>
Return current item: MyPHPBib