-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
70 lines (64 loc) · 1.78 KB
/
user.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
<?php require 'init.php'; ?>
<?php include 'head.php'; ?>
<body>
<?php include 'dashboard_navbar.php'; ?>
<h3>Add User</h3>
<div class="row">
<div class="col-md-4">
<form method="post">
<div class="form-group">
<label class="control-label">Username:</label>
<input type="text" name="username" class="form-control" required>
</div>
<div class="form-group">
<label class="control-label">Password:</label>
<input type="text" name="password" class="form-control" required>
</div>
<button name="submit" class="btn btn-xs btn-default">Submit</button>
</form>
</div>
<?php
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$query = $db->query("INSERT INTO auth(username,password)VALUES('$username','$password') ");
if($query){ ?>
<script>
alert("User added !");
window.location = 'user.php';
</script>
<?php
}
}
?>
<div class="col-md-8">
<table class="table table-bordered table-hover project_table">
<thead>
<tr>
<th>S/N</th>
<th>Username</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<?php
$query = $db->query("SELECT * FROM auth");
$rows = $query->fetchAll(PDO::FETCH_OBJ);
foreach($rows as $row){
$name = $row->username;
$id = $row->id;
$passkey = $row->password;
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $name; ?></td>
<td><?php echo $passkey; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<?php include 'footer.php'; ?>