<?php
session_start();

if (isset($_POST['username'])and isset($_POST['password']) and isset($_POST['fullname']) and isset($_POST['email']) and isset($_POST['priv'])) {
	
	include ("../includes/db.php");
	
	$username = mysql_escape_string($_POST['username']);
	$password = mysql_escape_string(md5($_POST['password']));
	$fullname = mysql_escape_string($_POST['fullname']);
	$email = mysql_escape_string($_POST['email']);
	$priv = mysql_escape_string($_POST['priv']);
	
	// INSERT USER
	$query = "INSERT INTO user (Username, Password, Fullname, Email, Privilegy, Verified) VALUES ('$username', '$password', '$fullname', '$email', '$priv', 1) ";
	mysql_query ($query);
	$newUserId = mysql_insert_id();
	
	// INSER NOTE
	$note = "Your account is successfully created. Welcome!";
	$query = "INSERT INTO note (Content) VALUES ('$note') ";
	mysql_query ($query);
	
	
	// INSERT USER_NOTE
	$noteId = mysql_insert_id();
	$query = "INSERT INTO user_note (UserId, NoteId) VALUES ('$newUserId', '$noteId') ";
	mysql_query ($query);	
	
	echo "success";
}

?>