forked from prodgrammer21/PHP-CRUD-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
114 lines (97 loc) · 3.08 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
<?php
require("./read.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT"
crossorigin="anonymous">
<title>PHP CRUD by bossROD</title>
</head>
<style>
html,
body {
margin: 0;
padding: 0;
}
.main {
height: 20vh;
/* Grid */
display: grid;
grid-template-rows: auto auto 1fr;
justify-items: center;
row-gap: 20px;
}
.main .create-main {
grid-row: 1/2;
display: grid;
grid-auto-rows: auto;
row-gap: 5px;
}
.main .create-main h3 {
text-align: center;
}
.main .export-main {
grid-row: 2/3;
}
.main .read-main {
grid-row: 3/4;
}
.main .read-main tr th {
width: 200px;
}
.main .read-main tr td {
text-align: center;
}
.main .read-main tr td:nth-child(4) {
display: grid;
grid-auto-flow: column;
}
</style>
<body>
<div class="main ">
<form class="create-main" action="/php-crud-tutorial/create.php" method="post">
<h3>CREATE USER:</h3>
<input type="text" name="username" placeholder="Enter username" required />
<input type="password" name="password" placeholder="Enter password" required />
<input type="submit" name="create" value="CREATE">
</form>
<form class="export-main" action="/php-crud-tutorial/pdf.php" method="post">
<input type="submit" name="exportToPdf" value="EXPORT TO PDF" />
</form>
<table class="read-main">
<tr>
<th><a href="?column=id&sort=<?php echo $sort ?>">ID</a></th>
<th><a href="?column=username&sort=<?php echo $sort ?>">USERNAME</a></th>
<th><a href="?column=password&sort=<?php echo $sort ?>">PASSWORD</a></th>
<th>ACTIONS</th>
</tr>
<?php while ($results = mysqli_fetch_array($sqlAccounts)) { ?>
<tr>
<td><?php echo $results['id']; ?></td>
<td><?php echo $results['username']; ?></td>
<td><?php echo $results['password']; ?></td>
<td>
<form action="/php-crud-tutorial/update.php" method="post">
<input type="submit" name="edit" value="EDIT" />
<input type="hidden" name="editId" value="<?php echo $results['id']; ?>" />
<input type="hidden" name="editUsername" value="<?php echo $results['username']; ?>" />
<input type="hidden" name="editPassword" value="<?php echo $results['password']; ?>" />
</form>
<form action="/php-crud-tutorial/delete.php" method="post">
<input type="submit" name="delete" value="DELETE" />
<input type="hidden" name="deleteId" value="<?php echo $results['id']; ?>" />
</form>
</td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>