-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
152 lines (135 loc) · 5.54 KB
/
index.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
<!DOCTYPE html>
<html lang="tr-TR">
<head>
<meta charset='UTF-8'/>
<title>yPhoneBook</title>
<!-- META -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="tr" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="description" content="Example PHP project using modern technologies Bootstrap, jQuery, AJAX and ezSQL" />
<meta name="keywords" content="yakuter,yPhoneBook,Ajax,PHP,MySQL,ezSQL" />
<meta name="robots" content="all" />
<meta name="author" content="Erhan YAKUT - http://www.yakuter.com" />
<!-- CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
<!-- JS -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/custom.js"></script>
</head>
<body>
<!-- DATABASE CONNECTION -->
<?php
include_once "includes/ez_sql_core.php";
include_once "includes/ez_sql_mysqli.php";
include_once "includes/config.php";
$db = new ezSQL_mysqli($db_user, $db_password, $db_name, $db_host);
$db->query("SET NAMES utf8");
?>
<!-- //DATABASE CONNECTION -->
<div class="container" role="main">
<div class="row rc">
<div class="col-md-7 cc">
<div class="page-header">
<h1>yPhoneBook</h1>
</div>
<div id="actions">
<button type="button" class="btn btn-sm btn-primary" id="ListAll">List All</button>
<button type="button" class="btn btn-sm btn-success" id="show_new_form">New Contact</button>
<button type="button" class="btn btn-sm btn-info" id="show_search_form">Search</button>
</div>
<div id="new_contact" class="forms">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">New Contact</h3>
</div>
<div class="panel-body">
<form name="newContactForm" id="newContactForm" method="post">
<div class="input-group pull-left">
<input type="text" name="name" class="form-control" placeholder="Name Surname">
</div>
<div class="input-group pull-left">
<input type="text" name="phone" class="form-control" placeholder="Phone">
</div>
<div class="input-group pull-left">
<input type="text" name="email" class="form-control" placeholder="Email">
</div>
<button type="button" class="btn btn-sm btn-warning pull-left" id="addButton">Add</button>
</form>
</div>
</div>
</div>
<div id="searchBox" class="forms">
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title">Search</h3>
</div>
<div class="panel-body">
<form name="searchForm" id="searchForm" method="post">
<div class="input-group pull-left">
<input type="text" name="search" class="form-control" placeholder="Search">
</div>
<button type="button" class="btn btn-sm btn-warning pull-left" id="searchButton">Search</button>
</form>
</div>
</div>
</div>
<div id="edit_contact" class="forms"></div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Contact List</h3>
</div>
<div class="panel-body" id="tableList">
<div id="loading"></div>
<table class="table" id="contactsTable">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Phone</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!isset($_GET['b'])) { $b=0; } else { $b = $_GET['b']; }
if (isset($_POST['search'])) {$kosul=" WHERE name LIKE '%".$_POST['search']."%' OR phone LIKE '%".$_POST['search']."%' OR email LIKE '%".$_POST['search']."%'";}
else {$kosul='';}
$sql="SELECT * FROM $db_table $kosul ORDER BY id DESC";
$contacts = $db->get_results($sql);
if ($contacts!='') {
foreach ( $contacts as $contact ) {
?>
<tr id="<?php echo $contact->id; ?>">
<td><?php echo $contact->id; ?></td>
<td><?php echo $contact->name; ?></td>
<td><?php echo $contact->phone; ?></td>
<td><?php echo $contact->email; ?></td>
<td>
<button type="submit" value="<?php echo $contact->id;?>" class="btn btn-sm btn-warning pull-left editButton">Edit</button>
<button type="submit" value="<?php echo $contact->id;?>" class="btn btn-sm btn-danger pull-left delButton">Delete</button>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
<footer class="rc">
<a href="http://www.yakuter.com/yphonebook" title="yPhoneBook">yPhoneBook</a> |
<a href="https://github.com/yakuter/yPhoneBook" title="GitHub">Github</a> |
Copyright © 2017 |
<a href="http://www.yakuter.com/">Yakuter.com</a>
</footer>
</div>
</div>
</div>
</body>
</html>