This commit is contained in:
2024-06-24 07:52:54 +02:00
parent 4cf0c7bcb9
commit 6e1ecbc485
146 changed files with 964 additions and 59 deletions

316
add_user.php Normal file
View File

@@ -0,0 +1,316 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.rtl.min.css" integrity="sha384-gXt9imSW0VcJVHezoNQsP+TNrjYXoGcrqBZJpry9zJt8PCQjobwmhMGaDHTASo9N" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style/style.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://kit.fontawesome.com/4bb6479073.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
<title>Globaly - Full Cycle Business Management & Consulting Responsive WordPress Theme</title>
<style>
#generate-password {
top: 40%;
right: 50px;
position: absolute;
cursor: pointer;
}
.fa-solid {
position: absolute;
right: 3%;
top: 41%;
cursor: pointer;
}
#pswd_info {
position: absolute;
bottom: 25%;
bottom: -115px\9;
/* IE Specific */
right: 1%;
width: 400px;
padding: 15px;
background: #fefefe;
font-size: .875em;
border-radius: 5px;
box-shadow: 0 1px 3px #ccc;
border: 1px solid #ddd;
}
#pswd_info {
display: none;
}
#pswd_info h4 {
margin: 0 0 10px 0;
padding: 0;
font-weight: normal;
}
#pswd_info::before {
content: "\25B2";
position: absolute;
top: -12px;
left: 45%;
font-size: 14px;
line-height: 14px;
color: #ddd;
text-shadow: none;
display: block;
}
.invalid {
padding-left: 22px;
line-height: 24px;
color: #ec3f41;
}
.valid {
padding-left: 22px;
line-height: 24px;
color: #3a7d34;
}
@media screen and (min-width: 768px) {
.fa-solid {
top: 41%;
}
#pswd_info {
bottom: 35%;
right: 30%;
}
}
@media screen and (min-width: 992px) {
.fa-solid {
top: 40%;
}
#pswd_info {
bottom: 15%;
right: 38%;
}
}
.date-container {
width: 100%;
display: flex;
span {
margin-right: 20px;
}
}
</style>
</head>
<body>
<div class="form d-flex flex-column align-items-center justify-content-center my-md-5 mb-5 mb-lg-0">
<div class="headline-card d-flex flex-column align-items-center justify-content-center mt-4">
<h2>Add new user</h2>
<img class="line-img" src="assets/images/line.png" alt="">
</div>
<form action="php/add_user_register.php" method="post">
<div class="form-container-bot d-flex flex-column align-items-start justify-content-center">
<input class="input-text" type="text" placeholder="User's Name" name="name">
<input class="input-text" type="text" placeholder="User's Surname" name="surname">
<input class="input-text" type="text" placeholder="User's Email" name="email">
<input class="input-text" type="password" id="password" placeholder="Password" name="password">
<i id="togglePassword" class="fa-solid fa-eye"></i>
<p id="generate-password">generete</p>
<input class="input-text" type="password" id="confirm-password" placeholder="Confirm Password" name="password_again">
<input class="input-text" type="text" placeholder="User's City" name="city">
<h6>Date of birth:</h6>
<div class="date-container">
<span>
<select name="birth_day">
<?php
$start_date = 1;
$end_date = 31;
for ($j = $start_date; $j <= $end_date; $j++) {
echo '<option value=' . $j . '>' . $j . '</option>';
}
?>
</select>
</span>
<span>
<select name="birth_month">
<?php for ($m = 1; $m <= 12; ++$m) {
$month_label = date('F', mktime(0, 0, 0, $m, 1));
?>
<option value="<?php echo $month_label; ?>"><?php echo $month_label; ?></option>
<?php } ?>
</select>
</span>
<span>
<select name="birth_year">
<?php
$year = date('Y');
$min = $year - 100;
$max = $year;
for ($i = $max; $i >= $min; $i--) {
echo '<option value=' . $i . '>' . $i . '</option>';
}
?>
</select>
</span>
<div class="checkbox-container">
Administrator:
<input type="checkbox" id="exampleCheckbox" name="admin">
<input type="hidden" id="exampleCheckboxValue" name="admin" value="0">
</div>
</div>
<input class="view-more" type="submit" value="Add user">
</div>
</form>
<div id="pswd_info">
<h4>Password must meet the following requirements:</h4>
<ul>
<li id="letter" class="invalid">At least <strong>one letter</strong></li>
<li id="capital" class="invalid">At least <strong>one capital letter</strong></li>
<li id="number" class="invalid">At least <strong>one number</strong></li>
<li id="character" class="invalid">At least <strong>one special character</strong></li>
<li id="length" class="invalid">Be at least <strong>8 characters</strong></li>
</ul>
</div>
<a href="admin_panel.php"><input class="view-more" type="submit" value="Back"></a>
<script>
$(document).ready(function() {
// Function to validate password
function validatePassword() {
var pswd = $('#password').val();
// Validate the length
if (pswd.length < 8) {
$('#length').removeClass('valid').addClass('invalid');
} else {
$('#length').removeClass('invalid').addClass('valid');
}
// Validate letter
if (pswd.match(/[A-Za-z]/)) {
$('#letter').removeClass('invalid').addClass('valid');
} else {
$('#letter').removeClass('valid').addClass('invalid');
}
// Calidate Capital letter
if (pswd.match(/[A-Z]/)) {
$('#capital').removeClass('invalid').addClass('valid');
} else {
$('#capital').removeClass('valid').addClass('invalid');
}
// Validate Number
if (pswd.match(/[0-9]/)) {
$('#number').removeClass('invalid').addClass('valid');
} else {
$('#number').removeClass('valid').addClass('invalid');
}
// Validate special character
if (pswd.match(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/)) {
$('#character').removeClass('invalid').addClass('valid');
} else {
$('#character').removeClass('valid').addClass('invalid');
}
}
// Bind events
$('#password').on('keyup focus blur', function() {
$('#pswd_info').show();
validatePassword();
});
$('#password').blur(function() {
$('#pswd_info').hide();
});
// Toggle Password show
$("#togglePassword").removeClass("fa-solid fa-eye").addClass("fa-solid fa-eye-slash");
$("#togglePassword").click(function() {
const passwordInput = $("#password");
const type = passwordInput.attr("type");
if (type === "password") {
passwordInput.attr("type", "text");
$("#togglePassword").removeClass("fa-solid fa-eye-slash").addClass("fa-solid fa-eye");
} else {
passwordInput.attr("type", "password");
$("#togglePassword").removeClass("fa-solid fa-eye").addClass("fa-solid fa-eye-slash");
}
});
$('#generate-password').click(function() {
const password = generatePassword(8);
$('#password').val(password);
$('#confirm-password').val(password);
});
function generatePassword(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+[]{}|;:,.<>?';
let password = '';
do {
password = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
password += characters[randomIndex];
}
} while (!isPasswordValid(password));
return password;
}
function isPasswordValid(password) {
if (password.length < 8) {
return false;
}
if (!/[a-z]/.test(password)) {
return false;
}
if (!/[A-Z]/.test(password)) {
return false;
}
if (!/\d/.test(password)) {
return false;
}
if (!/[!@#$%^&*()_+[\]{}|;:,.<>?]/.test(password)) {
return false;
}
return true;
}
function updateCheckboxValue() {
const isChecked = $('#exampleCheckbox').is(':checked');
$('#exampleCheckboxValue').val(isChecked ? '1' : '0');
}
$('#exampleCheckbox').change(function() {
updateCheckboxValue();
});
updateCheckboxValue();
});
</script>
</body>
</html>