-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_notes.php
79 lines (71 loc) · 3.02 KB
/
manage_notes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
include('system_load.php');
//This loads system.
//user Authentication.
authenticate_user('all');
$note_obj = new Notes;
//updating Notes
if(isset($_POST['update_note'])) {
extract($_POST);
$message = $note_obj->update_note($edit_note, $note_title, $note_detail);
}//update ends here.
//setting level data if updating or editing.
if(isset($_POST['edit_note'])) {
$note_obj->set_note($_POST['edit_note']);
} //level set ends here
//add user processing.
if(isset($_POST['add_note']) && $_POST['add_note'] == '1') {
extract($_POST);
if($note_title == '') {
$message = 'Note Title is required!';
} else if($note_detail == '') {
$message = 'Note Detail is required!';
} else {
$message = $note_obj->add_note($note_title, $note_detail);
}
}//add user processing ends here.
if(isset($_POST['edit_note'])){ $page_title = 'Edit note'; } else { $page_title = 'Add New Note';} //page title set.
require_once("includes/header.php"); //including header file.
?>
<?php
//display message if exist.
if(isset($message) && $message != '') {
echo '<div class="alert alert-success">';
echo $message;
echo '</div>';
}
?>
<div class="col-sm-8">
<form action="<?php $_SERVER['PHP_SELF']?>" id="add_user" name="user" method="post" enctype="multipart/form-data" role="form">
<div class="form-group">
<label class="control-label">Note Title*</label>
<input type="text" class="form-control" name="note_title" placeholder="Note title" value="<?php echo $note_obj->note_title; ?>" required="required" />
</div>
<div class="form-group">
<label class="control-label">Note Detail*</label>
<textarea name="note_detail" class="form-control" placeholder="Note Detail"><?php echo $note_obj->note_detail; ?></textarea>
</div>
<?php
if(isset($_POST['edit_note'])){
echo '<input type="hidden" name="edit_note" value="'.$_POST['edit_note'].'" />';
echo '<input type="hidden" name="update_note" value="1" />';
} else {
echo '<input type="hidden" name="add_note" value="1" />';
} ?>
<div class="form-group">
<input type="submit" value="<?php if(isset($_POST['edit_note'])){ echo 'Update Note'; } else { echo 'Add Note';} ?>" class="btn btn-primary" />
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
// validate the register form
$("#add_user").validate();
});
</script>
</div><!--left-side-form ends here.-->
<?php
require_once('includes/sidebar.php');
?>
<?php
require_once("includes/footer.php");
?>