-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.php
131 lines (110 loc) · 4.21 KB
/
Home.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
ob_start();
session_start();
require_once 'dbconnect.php';
// if session is not set this will redirect to login page
if( !isset($_SESSION['user']) ) {
header("Location: index.php");
exit;
}
// select loggedin users detail
$res=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['userEmail']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#FormSubmit").click(function (e) {
e.preventDefault();
if($("#contentText").val()==='')
{
alert("Please enter some text!");
return false;
}
$("#FormSubmit").hide(); //hide submit button
$("#LoadingImage").show(); //show loading image
var myData = 'content_txt='+ $("#contentText").val();
jQuery.ajax({
type: "POST",
url: "response.php",
dataType:"text",
data:myData,
success:function(response){
$("#responds").append(response);
$("#contentText").val('');
$("#FormSubmit").show();
$("#LoadingImage").hide();
},
error:function (xhr, ajaxOptions, thrownError){
$("#FormSubmit").show();
$("#LoadingImage").hide();
alert(thrownError);
}
});
});
//##### Send delete Ajax request to response.php #########
$("body").on("click", "#responds .del_button", function(e) {
e.preventDefault();
var clickedID = this.id.split('-');
var DbNumberID = clickedID[1];
var myData = 'recordToDelete='+ DbNumberID;
$('#item_'+DbNumberID).addClass( "sel" );
$(this).hide();
jQuery.ajax({
type: "POST",
url: "response.php",
dataType:"text",
data:myData,
success:function(response){
$('#item_'+DbNumberID).fadeOut();
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
});
});
</script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="content_wrapper">
<ul id="responds">
<?php
//include db configuration file
include_once("config.php");
$add_delete="add_delete";
//MySQL query
$results = $mysqli->query("SELECT id,content,emailid FROM ".$add_delete."");
//get all records from add_delete_record table
while($row = $results->fetch_assoc())
{
if($row["emailid"]==$userRow['userEmail'])
{
echo '<li id="item_'.$row["id"].'" class="bg-success">';
echo '<div class="del_wrapper bg-success"><a href="#" class="del_button" id="del-'.$row["id"].'">';
echo '<img src="images/icon_del.gif" border="0" />';
echo '</a></div>';
echo $row["content"].'</li>';}
}
//close db connection
$mysqli->close();
?>
</ul>
<div class="form_style">
<textarea name="content_txt" id="contentText" cols="45" rows="5" placeholder="Enter some text"></textarea>
<button id="FormSubmit">Add NOTES</button>
<img src="images/loading.gif" id="LoadingImage" style="display:none" />
</div>
</div>
<a href="Logout.php?logout=+a" class="btn btn-default" >logout</a>
</body>
</html>
<?php ob_end_flush(); ?>