-
Notifications
You must be signed in to change notification settings - Fork 0
/
adduser.php
107 lines (94 loc) · 3.21 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
104
105
106
107
<!DOCTYPE html>
<html lang="en">
<?php
session_start();
$con = mysqli_connect('localhost', 'root', '');
if (empty($_SESSION['username'])) {
header('location:index.php');
}
mysqli_select_db($con, 'mms');
?>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>add user</title>
</head>
<body>
<style>
</style>
<div class="card">
<div class="card-header">
MMS
</div>
<div class="card-body row">
<button class="btn"> <a href="admin/admins.php">Back </a> </button>
<h5 class="card-title" style="text-align: center;margin:auto;">Add User</h5>
</div>
</div>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$username=$_POST['username'];
$q = "select * from users where username = '$username'";
$res = mysqli_query($con, $q);
$qarr = mysqli_fetch_assoc($res);
}
?>
<form style="margin:20px auto; width: 40vw;" method="POST" action="">
<div class="form-group row">
<label for="inputPassword" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="text" name='username' class="form-control" placeholder="Email">
</div>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$username = $_POST['username'];
$name = $_POST['name'];
$user_type = $_POST['user_type'];
$password = $_POST['password'];
$q = "select username from users where username='$username'";
$res = mysqli_query($con,$q);
if(mysqli_num_rows($res)!=0){
echo "Email already used";
}
else{
$q2 = "insert into users values ('$username', '$name', '$user_type', '$password')";
if($user_type=="owner"){
$q3 = "insert into owner (name,username) values ('$name','$username')";
$res_3 = mysqli_query($con, $q3);
}
$res_2 = mysqli_query($con, $q2);
header('location: added.php');
}
}
?>
</div>
<div class="form-group row">
<label for="inputPassword" class="col-sm-2 col-form-label">User Type</label>
<div class="col-sm-10">
<select name="user_type" id="cars" >
<option value="admin">Admin</option>
<option value="floor_manager">floor_manager</option>
<option value="shop_manager">shop_manager</option>
<option value="owner">Owner</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="inputPassword" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<input type="text" name='name' class="form-control" placeholder="Name">
</div>
</div>
</div>
<div class="form-group row">
<label for="inputPassword" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-10">
<input type="password" name='password' class="form-control" id="inputPassword" placeholder="Password" >
</div>
</div>
<input type="submit" value="Save">
</form>
</body>
</html>