Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Toggle View for Password field during signup and login #18 #39

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 119 additions & 93 deletions login.php
Original file line number Diff line number Diff line change
@@ -1,134 +1,160 @@
<!DOCTYPE html>
<html lang="en">
<?php
<?php
session_start();
include('./db_connect.php');
ob_start();
// if(!isset($_SESSION['system'])){
include ('./db_connect.php');
ob_start();
// if(!isset($_SESSION['system'])){

$system = $conn->query("SELECT * FROM system_settings")->fetch_array();
foreach($system as $k => $v){
$_SESSION['system'][$k] = $v;
}
// }
ob_end_flush();
$system = $conn->query("SELECT * FROM system_settings")->fetch_array();
foreach ($system as $k => $v) {
$_SESSION['system'][$k] = $v;
}
// }
ob_end_flush();
?>
<?php
if(isset($_SESSION['login_id']))
header("location:index.php?page=home");
<?php
if (isset($_SESSION['login_id']))
header("location:index.php?page=home");

?>
<?php include 'header.php' ?>

<style>
.login-logo {
text-align: center;
margin-bottom: 20px; /* Adjust as needed */
margin-bottom: 20px;
/* Adjust as needed */
}

.login-logo img {
width: 200px; /* Set the width as per your requirements */
height: auto; /* This maintains the image's aspect ratio */
width: 200px;
/* Set the width as per your requirements */
height: auto;
/* This maintains the image's aspect ratio */
}
</style>

<body class="hold-transition login-page bg-white">

<h2><b>COER AQMS</b></h2>
<div class="login-box">
<div class="login-logo">
<a href="#" class="text-white"></a>
</div>
<!-- /.login-logo -->
<div class="login-box">
<div class="login-logo">
<a href="#" class="text-white"></a>
</div>
<!-- /.login-logo -->


<div class="card">
<div class="card-body login-card-body">
<div class="card">
<div class="card-body login-card-body">
<div class="login-logo">
<img src="profpraisal.png" alt="Your Image Alt Text">
<img src="profpraisal.png" alt="Your Image Alt Text">
</div>
<form action="" id="login-form">
<!-- <div class="card">
<!-- <div class="card">
<div class="card-body login-card-body">
<form action="" id="login-form"> -->
<div class="input-group mb-3">
<input type="email" class="form-control" name="email" required placeholder="Email">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control" name="password" required placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock"></span>
<div class="input-group mb-3">
<input type="email" class="form-control" name="email" required placeholder="Email">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>
</div>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="">Login As</label>
<select name="login" id="" class="custom-select custom-select-sm">
<option value="3">Student</option>
<option value="2">Faculty</option>
<option value="1">Admin</option>
</select>
</div>
<div class="row">
<div class="col-8">
<div class="icheck-primary">
<input type="checkbox" id="remember">
<label for="remember">
Remember Me
</label>
<div class="input-group mb-3">
<input type="password" class="form-control" name="password" required placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock" onclick="togglePasswordVisibility()"></span>
<span class="fas fa-eye" style="display:none;" onclick="togglePasswordVisibility()"></span>
</div>
</div>
</div>
<!-- /.col -->
<div class="col-4">
<button type="submit" class="btn btn-primary btn-block">Sign In</button>
<div class="form-group mb-3">
<label for="">Login As</label>
<select name="login" id="" class="custom-select custom-select-sm">
<option value="3">Student</option>
<option value="2">Faculty</option>
<option value="1">Admin</option>
</select>
</div>
<p class="mb-1">
Don't have an account? <a href="signup.php" class="text-center">Sign up</a>
</p>
<div class="row">
<div class="col-8">
<div class="icheck-primary">
<input type="checkbox" id="remember">
<label for="remember">
Remember Me
</label>
</div>
</div>
<!-- /.col -->
<div class="col-4">
<button type="submit" class="btn btn-primary btn-block">Sign In</button>
</div>
<p class="mb-1">
Don't have an account? <a href="signup.php" class="text-center">Sign up</a>
</p>

<!-- /.col -->
</div>
</form>
<!-- /.col -->
</div>
</form>
</div>
<!-- /.login-card-body -->
</div>
<!-- /.login-card-body -->
</div>
</div>
<!-- /.login-box -->
<script>
$(document).ready(function(){
$('#login-form').submit(function(e){
e.preventDefault()
start_load()
if($(this).find('.alert-danger').length > 0 )
$(this).find('.alert-danger').remove();
$.ajax({
url:'ajax.php?action=login',
method:'POST',
data:$(this).serialize(),
error:err=>{
console.log(err)
end_load();
<!-- /.login-box -->
<script>
$(document).ready(function () {
$('#login-form').submit(function (e) {
e.preventDefault()
start_load()
if ($(this).find('.alert-danger').length > 0)
$(this).find('.alert-danger').remove();
$.ajax({
url: 'ajax.php?action=login',
method: 'POST',
data: $(this).serialize(),
error: err => {
console.log(err)
end_load();

},
success:function(resp){
if(resp == 1){
location.href ='index.php?page=home';
}else{
$('#login-form').prepend('<div class="alert alert-danger">Username or password is incorrect.</div>')
end_load();
}
}
},
success: function (resp) {
if (resp == 1) {
location.href = 'index.php?page=home';
} else {
$('#login-form').prepend('<div class="alert alert-danger">Username or password is incorrect.</div>')
end_load();
}
}
})
})
})
})
})
</script>
<?php include 'footer.php' ?>
</script>
<script>
function togglePasswordVisibility() {
var passwordInput = document.querySelector('[name="password"]');
var lockIcon = document.querySelector('.fa-lock');
var eyeIcon = document.querySelector('.fa-eye');

// Check if the password is currently visible
if (passwordInput.type === 'password') {
// If hidden, change to 'text' to show it and toggle icons
passwordInput.type = 'text';
lockIcon.style.display = 'none';
eyeIcon.style.display = 'block';
} else {
// If visible, change to 'password' to hide it and toggle icons
passwordInput.type = 'password';
lockIcon.style.display = 'block';
eyeIcon.style.display = 'none';
}
}

</script>
<?php include 'footer.php' ?>

</body>

</html>
Loading