-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadduser.php
103 lines (89 loc) · 3.9 KB
/
adduser.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
<?php
require 'includes/snippet.php';
require 'includes/db-inc.php';
include "includes/header.php";
if (isset($_POST['submit'])) {
//Getting the values from the forms
$name = sanitize(trim($_POST['name']));
$username = sanitize(trim($_POST['username']));
$password1 = sanitize(trim($_POST['password1']));
$password2 = sanitize(trim($_POST['password2']));
$email = sanitize(trim($_POST['email']));
//Check if the password matches
if ($password1 == $password2) {
//create an sql statement
$sql = "INSERT into admin (adminName, password, username, email) values ('$name', '$password1', '$username', '$email')";
//query the database
$query = mysqli_query($conn, $sql);
$error = false;
if ($query) {
$error = true;
header("refresh:2; users.php");
}
else {
echo "<script>alert('Failed!');
</script>";
}
}
else {
echo "<script>alert('Password mismatched!')</script>";
}
}
?>
<div class="container">
<?php include "includes/nav.php"; ?>
<div class="container col-lg-9 col-md-11 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-1 col-sm-offset-0 col-xs-offset-0 " style="margin-top: 30px">
<div class="jumbotron login col-lg-10 col-md-11 col-sm-12 col-xs-12">
<?php if(isset($error)) { ?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Record Added Successfully!</strong>
</div>
<?php } ?>
<p class="page-header" style="text-align: center">ADD ADMIN</p>
<div class="container">
<form class="form-horizontal" role="form" method="post" action="adduser.php" enctype="multipart/form-data">
<div class="form-group">
<label for="Name" class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" placeholder="Enter Full Name" id="name" required>
</div>
</div>
<div class="form-group">
<label for="Username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="username" placeholder="Enter Username" id="username" required>
</div>
</div>
<div class="form-group">
<label for="Password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="password1" placeholder="Enter Password" id="password" required>
</div>
</div>
<div class="form-group">
<label for="Password" class="col-sm-2 control-label">Confirm Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="password2" placeholder="Enter Password" id="password" required>
</div>
</div>
<div class="form-group">
<label for="Password" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="email" placeholder="Enter email" id="email" required>
</div>
</div>
<div class="form-group ">
<div class="col-sm-offset-2 col-sm-10 ">
<button type="submit" class="btn btn-info col-lg-4 " name="submit">
Submit
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>