-
Notifications
You must be signed in to change notification settings - Fork 0
/
onlogin.php
247 lines (236 loc) · 6 KB
/
onlogin.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
include_once "boot.php";
//require_once "addcontact.php";
session_start();
$usr=$_SESSION['Username'];
$id=$_SESSION['id'];
?>
<html>
<head>
<title>ACCESS IT!</title>
<style type="text/css">
.nav{
background-color:#420021;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 34px;
}
#add{
position:fixed;
top:0px;
left:15px;
padding:5px;
background-color:#420021;
font-size:15px;
}
#welcome{
position:fixed;
top:0px;
right:15px;
padding:5px;
background-color:#420021;
font-size:15px;
color: white;
}
#addcontact{
position: fixed;
top:35px;
background-color: #420021;
font-size: 15px;
color:white;
display: none;
padding: 5px;
}
#account{
position: fixed;
top: 35px;
right: 15px;
background-color: #420021;
font-size: 15px;
color: white;
display: none;
}
#account td{
padding: 10px;
}
.clickable:hover{
cursor:pointer;
opacity:0.8;
}
.clickable:active{
cursor: pointer;
position: relative;
top:2px;
}
#table td{
padding:5px;
}
#view{
position: absolute;
top: 100px;
left:200px;
padding: 10px;
font-size: 18px;
font-family: cursive;
}
#view td{
border: 1px solid black;
padding: 10px;
}
#search{
position: absolute;
top:50px;
right: 50px;
color:black;
}
#search td{
padding: 10px;
}
</style>
<script src = "jquery-1.11.3.min.js"></script>
<script type="text/javascript">
var b=0;
function addclicked () {
document.getElementById('addcontact').style.display="block";
}
function cancel(){
document.getElementById('name').value=document.getElementById('phno').value="";
document.getElementById('address').value=document.getElementById('email').value="";
document.getElementById('addcontact').style.display="none";
}
function welcomeclicked(){
if(b%2!=0)
document.getElementById('account').style.display="none";
else
document.getElementById('account').style.display="block";
b++;
}
function save(){
var ph=document.getElementById('phno').value;
for(var z in ph)
{
if(!(ph[z]>='0'&&ph[z]<='9'||ph[z]=='+'))
{
alert("Contact no. is a numeric field");
return false;
}
}
document.getElementById('addcontact').style.display="none";
var postData=$("#addcontactform").serializeArray();
var request=$.ajax({
url: "addcontact.php",
type: "POST",
data: postData
});
printsave();
}
function printsave(){
$.get("printcontacts.php",function(data){
console.log($.parseJSON(data));
data=$.parseJSON(data);
$("#view").html("");
$("#view").html('<tr style="font-size:22px;"><b><td>NAME</td><td>CONTACT NUMBER</td><td>ADDRESS</td><td>EMAIL ID</td></b></tr>');
for(var i in data)
{
$("#view").append("<tr><td>" + data[i].Name + "</td><td><a href='tel:" + data[i].PhoneNo + "'>"+data[i].PhoneNo +"</a></td><td>" + data[i].Address +"</td><td>"+ data[i].Email+"</td><td class='clickable' onclick='delete()'>DELETE</td></tr>").fadeIn("slow");
}
});
return false;
}
function signout()
{
$.get("signout.php");
document.location="forms.php";
}
function account()
{
document.location="account.php";
}
/*function delete()
{
$.get("delete.php"+"?Name="+arguments[0]+"&Ph="+arguments[1]+"?Address="+arguments[2]+"?Email="+arguments[3]);
printsave();
}*/
</script>
</head>
<body style="font-family:Papyrus;">
<div class="nav"></div>
<div id="add"><span class="clickable" style="color:white;" onclick="addclicked()">ADD</span></div>
<div id="welcome"><span class="clickable" onclick="welcomeclicked()">Welcome
<?php
@mysql_connect("localhost","root","") or die(mysql_error());
@mysql_select_db("accessit");
echo $usr;
?>
</span>
</div>
<div id="search">
<form action="" method="post">
<table>
<tr>
<td>SEARCH:</td>
<td><input type="textbox" placeholder="Name" name="search"></td>
<td><button class="btn btn-primary btn-xs" style="background-color:#420021;">GO</button></td>
</tr>
</table>
</form>
</div>
<table id="view">
<tr style="font-size:22px;">
<b>
<td>NAME</td>
<td>CONTACT NUMBER</td>
<td>ADDRESS</td>
<td>EMAIL ID</td>
<td>DELETE</td>
</b>
</tr>
<?php
printcontacts($id);
function printcontacts($id){
$query=mysql_query("select * from user where id='$id' order by Name");
if(!empty($_POST['search']))
{
$name=$_POST['search'];
$name=mysql_real_escape_string($name);
$query=mysql_query("select * from user where id='$id' AND Name like '%$name%' order by Name");}
while($row=mysql_fetch_assoc($query))
{
echo "<tr><td>".$row['Name']."</td><td>";?><a href="tel:<?php echo $row['PhoneNo'];?>"><?php echo $row['PhoneNo']."</a></td><td>".$row['Address']."</td><td>".$row['Email']."</td><td class='clickable' onclick='delete(".$row['Name'].",".$row['PhoneNo'].",".$row['Address'].",".$row['Email'].")'>DELETE</td></tr>";
}
}
?>
</table>
<div id="addcontact">
<form action="" id="addcontactform" method="post">
<table id="table" style="color:white; padding:5px;">
<tr>
<td>Name:</td><td><input type="textbox" id="name" name="name" style="color:black;"></td>
<td>Contact no.:</td><td><input type="textbox" id="phno" name="phone" style="color:black;"></td>
</tr>
<tr>
<td>Address:</td><td><input type="textarea" id="address" name="address" style="color:black;"></td>
<td>Email Id:</td><td><input type="email" id="email" name="email" style="color:black;"></td>
</tr>
<tr>
<td><input type="hidden" name="username" value="<?php echo $_SESSION['Username']; ?>"></td>
<td><input type="hidden" name="id" value="<?php echo $_SESSION['id']; ?>"></td>
</tr>
<tr>
<td><button type="button" class="btn btn-default btn-xs" onclick="save()">SAVE</button></td>
<td></td><td></td>
<td><button type="button" onclick="return cancel();" class="btn btn-default btn-xs">CANCEL</button></td>
</tr>
</table>
</form>
</div>
<div id="account">
<table>
<tr><td class="clickable" onclick="account()">Account details</td></tr>
<tr><td class="clickable" onclick="signout()">Sign Out</td></tr>
</table>
</div>
</body>
</html>