<?
/*
   File name         : createnote.php
   Version           : 1.1.0
   Last Modified By  : Umut Gokbayrak
   e-mail            : umut@trlinux.com
   Last modified     : 10 Sep 2000
*/

include ("includes/global.inc");
session_start();

if (trim($txttitle) == "") {
  $txttitle = $text40;
}

$txttitle=addslashes($_POST["txttitle"]);
$txtnote=addslashes($_POST["txtnote"]);
$ID=addslashes($_SESSION["ID"]);

// ID comparison between logged hash and session. If they are both the same, let the user to go on...
$dbq = $db->execute("select user_id,username,password from tblUsers where hash = '$ID'");
$user_id = $dbq->fields['user_id'];
$username = $dbq->fields['username'];
$password = $dbq->fields['password'];
$dbq->close();

if (($user_id == "") || (strlen($ID)==0)){
  Header("Location: index.php?error_id=1");
} else {

  $dbq = $db->execute("select note_id from tblNotebook order by note_id desc");
  $max_note_id   = $dbq->fields['note_id'];
  $dbq->close();
  $max_note_id++;

  $tarih = date('Y-m-d');
  $dbq = $db->execute("insert into tblNotebook values($max_note_id,$user_id,'$txttitle','$txtnote','$tarih')");
  Header("Location: notebook.php");
}

?>
