BBnepal-Accounts/application/views/student/login.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

173 lines
6.1 KiB
PHP

<div class="container-login">
<img src="<?php echo base_url(); ?>assets_student/images/LMS-Video-Animation-min.gif" class="login-image">
<!-- <video class="login-video" preload="metadata" playsinline autoplay muted loop >
<source src="<?php echo base_url(); ?>assets_student/images/login.webm#t=0.001" type="video/webm">
<source src="<?php echo base_url(); ?>assets_student/images/login.webm#t=0.001" type="video/webm">
Your browser does not support the video tag.
</video> -->
<header class="login-header">
<div class="login-wrap">
<div class="logo-wrap">
<img src="<?php echo base_url(); ?>common_assets/<?php echo $school_info['color_logo'] ?>">
</div>
</div>
<div class="header-menu-wrap">
<div class="login-mob-menu"><i class="fas fa-bars"></i></div>
<ul class="mob-menu">
<li><a href="#">About Us</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="<?php echo base_url(); ?>student/admission"><button class="join-class-btn">Admission Process ></button></a></li>
</ul>
</div>
</header>
<?php
$uname = ''; $pass = ''; $rme = 'Off';
if(isset($_COOKIE["username"]))
$uname = $_COOKIE["username"];
if(isset($_COOKIE["password"]))
$pass = $_COOKIE["password"];
if(isset($_COOKIE["rem_me"]))
$rme = $_COOKIE["rem_me"];
?>
<div class="login-body">
<div class="login-box-wrap">
<div class="login-box">
<h3>Student Login</h3>
<?php if($this->session->flashdata('success')) { ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<p><?php echo $this->session->flashdata('success') ?></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
<?php if($this->session->flashdata('danger')) { ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<p><?php echo $this->session->flashdata('danger') ?></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
<form id="loginform" method="post">
<div class="login-form-row">
<input type="text" name="email" id="email" value="<?php echo $uname;?>" placeholder="Enter Student Id">
<p id="email_error" style="color:red;"></p>
</div>
<div class="login-form-row">
<input type="password" name="password" id="password" value="<?php echo $pass;?>" placeholder="Enter password" class="password_hide">
<span class="passwrd-icon icon-y"><i class="far fa-eye"></i></span>
<p id="password_error" style="color:red;"></p><p id="invalid_error" style="color:red;"></p>
</div>
<div class="login-form-row">
<a href="<?php echo base_url(); ?>student/reset-password"><label class="forgotPswd">Forgot password?</label></a>
<span class="rem-paswd"><input type="checkbox" name="remember_me" <?php if($rme=='On'){?>checked<?php } ?> ><label>Remember Me</label></span>
</div>
<div class="login-form-row">
<button type="button" class="join-class-btn" onclick="validate_login_form()" >Login</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$(".passwrd-icon").click(function() {
$(".passwrd-icon").toggleClass("icon-y");
var input = $( ".password_hide");
if (input.attr("type") == "password") {
input.attr("type", "text");
} else {
input.attr("type", "password");
}
});
</script>
<script type="text/javascript">
function hide_all_login_errors()
{
$('#email_error').hide();
$('#password_error').hide();
}
function celanup_login_form()
{
$('#email').val('');
$('#passsword').val('');
$('#invalid_error').html('');
}
function validate_login_form(){
hide_all_login_errors();
var errArr = new Array();
var lemail = $('#email').val().trim();
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
/* if(lemail==''){
errArr.push('email_Sep@Str_Please enter your registered email address.');
}
else if(!regex.test(lemail)){
errArr.push('email_Sep@Str_Please enter a valid email address.');
}
*/
if(lemail==''){
errArr.push('email_Sep@Str_Please enter your StudentId.');
}
var lpwd = $('#password').val().trim();
if(lpwd==''){
errArr.push('password_Sep@Str_Please enter your password.');
}
if(errArr.length>0)
{
for(i=0; i<errArr.length; i++)
{
var resArr = errArr[i].split("_Sep@Str_");
$("#"+resArr[0]+"_error").html(resArr[1]);;
$("#"+resArr[0]+"_error").show();
}
var xxxVal = errArr[0].split('_Sep@Str_');
$('#'+xxxVal[0]).focus();
return false;
}
else{
$('#loginform').submit();
}
}
$('#loginform').submit(function(e){
e.preventDefault();
var formData = new FormData($("#loginform")[0]);
$.ajax({
url : '<?php echo base_url(); ?>Student/student_login',
dataType : 'json',
type : 'POST',
data : formData,
contentType : false,
processData : false,
success: function(response) {
console.log(response);
if(response == '1'){
window.location.href="<?php echo base_url(); ?>student/dashboard";
}else if(response == '0'){
$('#invalid_error').html("Invalid Student Id or Password.");
}
}
});
});
</script>