-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
212 lines (140 loc) · 4.6 KB
/
add.php
File metadata and controls
212 lines (140 loc) · 4.6 KB
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
<!DOCTYPE html>
<?php
include('database_connection.php');
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$flag = 0;
if(isset ($_POST['update'])){
echo "<script type='text/javascript'>alert('entered');</script>";
$flag=1;
}
//echo "<script type='text/javascript'>alert('".$flag."');</script>";
if($flag==1)
{
$sql = "select ufirstname,ulastname from user where username like '%".$_POST['firstname']."%'";
echo $sql;
//echo "<script type='text/javascript'>console.info('".$sql."');</script>";
$result = mysqli_query($conn,$sql);
while($row= mysqli_fetch_row($result))
{echo $row[0];
}
//echo "<script type='text/javascript'>alert('".$result."');</script>";
}
//echo "<script type='text/javascript'>alert('".$result."');</script>";
//echo "<script type='text/javascript'>alert('Signed Up Successfully!');</script>";
include 'navbar.php';
?>
<html>
<head>
<title>Web Chat Application Sign Up</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style type="text/css">
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 12%;
border-radius: 50%;
}
.container {
width: 50%;
padding: 16px;
}
.container1 {
width: 100%;
height: 500px;
padding: 16px;
}
#map-canvas {
margin: 0;
padding: 0;
height: 100%;
}
.button {
width:100%;
}
.topnav input[type=text] {
float: right;
padding: 6px;
border: none;
margin-top: 8px;
margin-right: 16px;
font-size: 17px;
}
/* When the screen is less than 600px wide, stack the links and the search field vertically instead of horizontally */
@media screen and (max-width: 600px) {
.topnav a, .topnav input[type=text] {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.topnav input[type=text] {
border: 1px solid #ccc;
}
}
</style>
</head>
<body>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading" align="center">Add friends</div>
<div class="panel-body">
<form method="post" name="myform">
<div class="col-xs-6">
<label>Search</label>
<input type="text" name="firstname" class="form-control" />
</div>
<div class="form-group">
<br>
<input type="submit" name="update" class="btn btn-info" value="Submit" />
</div>
<p><a href="index.php" style="color:dodgerblue">Go back to Home</a></p>
</form>
<div id='userthreads' align="center" width='70%'>
<?php
if($flag==1){
$sql = "select username,ufirstname,ulastname from user where username like '%".$_POST['firstname']."%'";
$result = mysqli_query($conn,$sql);
if (!$result) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
echo "<table id='searchtable'>";
echo "<th >Firstname</th><th >Lastname</th> <th>Add</th> ";
echo "<tr></tr>";
while($row = mysqli_fetch_array($result)) {
$v=$row['username'];
$sql2 = "insert into friends values ('$v','".$_SESSION['username']."',0)";
echo $sql2;
echo "<form action='add.php' method='post'><tr>
<td style='padding : 5px;' class = 'searchtable' >".$row['ufirstname']."</td>
<td style='padding : 5px;'>".$row['ulastname']."</td>
<td><input class='btn btn-info' name='submit' type='submit' value='add' onclick='Inc()' ></td>
</tr></form>";
}
echo "</table>";
}
?>
</div>
</div>
</div>
</div>
<script>
function Inc()
{
<?php
$result2 = mysqli_query($conn,$sql2);
echo "<script type='text/javascript'>alert('".$_SESSION['username']."');</script>";
?>
}
</script>
</body>
</html>