-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-admin.php
161 lines (156 loc) · 7.51 KB
/
create-admin.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
153
154
155
156
157
158
159
160
161
<?php
echo "<h5>
<center> Create Admin</center></h5>";
include_once "./db/User.php";
date_default_timezone_set('Africa/Cairo');
$successfully= false;
$errors1 ='';
$errors2 ='';
$errors3 ='';
$errors4 ='';
$errors5 ='';
$errors6 ='';
$errors7 ='';
$errors8 ='';
// validityNumber
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$fullName = $_POST['fullName'];
$age = $_POST['age'];
$date = $_POST['date'];
$password = $_POST['password'];
$userName = $_POST['userName'];
$gmail = $_POST['gmail'];
$validityNumber = $_POST['validityNumber'];
if (!$fullName && !$age && !$date && !$userName && !$password) {
$errors1 = 'Data must be filled';
}elseif(!$fullName ){
$errors2 ='You must type full name';
}elseif(!$age ){
$errors3 ='Age must be entered';
}elseif(!$date ){
$errors4 ='You must enter a date of birth';
}elseif(!$gmail ){
$errors4 ='You must enter an email';
}elseif(!$userName ){
$errors5 ='You must enter a username';
}elseif(!$password ){
$errors6 ='You must enter a password';
} elseif(strlen($password)<3 ){
$errors6 ='The password is weak';
} elseif($validityNumber !== "mahmoud123456"){
$errors8 ='Sorry, the validity number is incorrect';
} else {
$user = new User;
$notFound = $user->select(' *','admin')->where('User_Name','=',"$userName")->andWhere('Password','=',"$password")->print();
if (count($notFound)===0) {
# code...
$dateCreate = date("Y/m/d h:i:sa");
$user->insert('admin',$fullName,$age,$date,$password,$dateCreate,$userName,$gmail);
$successfully = 'Account successfully created';
sleep(2);
header("location: /E-Commerce/admin.php?u=$userName");
exit;
$_POST['age']='';
$_POST['date']='';
$_POST['password']='';
$_POST['userName']='';
}else{
$errors1 = 'This user already exists';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<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">
<title>MMA || Admin Sign In & Sign Up</title>
<link rel="shortcut icon"
href="https://yt3.ggpht.com/K8-YocA-7arl_4uKY_3LP8S3hj4LgTMRwGit9yIPCdfW-fDPGNyCh3XrucxXbTMq9lE20DMJqg=s600-c-k-c0x00ffffff-no-rj-rp-mo"
type="image/x-icon">
<!-- Get Bottstrap {css & js} -->
<link rel="stylesheet" href="./Front-End/assets/bottstrap/css/bootstrap.min.css">
<link rel="js" href="./Front-End/assets/bottstrap/js/bootstrap.min.js">
<!-- Get Taliwind -->
<script src="./Front-End/assets/Tailwindcss/tailwindcss.min.js"></script>
<!-- Get FontAwesome -->
<link rel="stylesheet" href="./Front-End/assets/fontawesome-free-6.1.1-web/all.min.js">
</head>
<body>
<main class="d-flex justify-content-center align-items-center" style="height: 100vh;">
<div class=" border p-3 rounded-lg col-12 col-sm-6 col-md-4">
<img class="w-20 mx-auto" src="./Front-End/Images/signUp-accont.jpg" alt="avatar">
<form action="./create-admin.php" method="post" enctype="multipart/form-data">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors1&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors1?></h6>
<div class="d-flex flex-column ">
<label for="fullName">Full Name:</label>
<input type="text" value="<?php if(isset($_POST['fullName'])){
echo $_POST['fullName'];
}?>" class="border rounded px-2 py-1" name="fullName" id="fullName">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors2&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors2?></h6>
</div>
<div class="d-flex flex-column ">
<label for="age">Age:</label>
<input type="number" value="<?php if(isset($_POST['age'])){
echo $_POST['age'];
}?>" class="border rounded px-2 py-1" name="age" id="age">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors3&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors3?></h6>
</div>
<div class="d-flex flex-column ">
<label for="date">Date:</label>
<input type="date" value="<?php if(isset($_POST['date'])){
echo $_POST['date'];
}?>" class="border rounded px-2 py-1" name="date" id="date">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors4&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors4?></h6>
</div>
<div class="d-flex flex-column ">
<label for="gmail">Gmail:</label>
<input type="gmail" value="<?php if(isset($_POST['gmail'])){
echo $_POST['gmail'];
}?>" class="border rounded px-2 py-1" name="gmail" id="gmail">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors7&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors7?></h6>
</div>
<div class="d-flex flex-column ">
<label for="userName">User Name:</label>
<input type="text" value="<?php if(isset($_POST['userName'])){
echo $_POST['userName'];
}?>" class="border rounded px-2 py-1" name="userName" id="userName">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors5&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors5?></h6>
</div>
<div class="d-flex flex-column ">
<label for="password">Password:</label>
<input type="password" value="<?php if(isset($_POST['password'])){
echo $_POST['password'];
}?>" class="border rounded px-2 py-1" name="password" id="password">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors6&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors6?></h6>
</div>
<div class="d-flex flex-column ">
<label for="validityNumber">Validity number:</label>
<input type="password" class="border rounded px-2 py-1" name="validityNumber" id="validityNumber">
<h6 class="text-white bg-red-400 text-center mt-1 <?php $errors8&&"px-3 py-2" ?> rounded-lg px-3">
<?=$errors8?></h6>
</div>
<div class="text-center"> <button type="submit"
class="rounded-full text-center bg-green-300 hover:bg-green-400 hover:text-white px-5 py-1 my-2 mx-auto ">Create
Accont</button>
</div>
</form>
<div class="text-center">
<a href="./admin.php" class="link underline my-1">Login</a>
</div>
</div>
<div class=" col-sm-6 col-md-4 text-center">
<img class="w-96 mx-auto" src="./Front-End/Images/signUp.webp" alt="Create-Accont">
</div>
</main>
</body>
</html>