142 lines
4.8 KiB
PHP
142 lines
4.8 KiB
PHP
|
<?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>Teacher 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">×</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">×</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 username">
|
||
|
<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(); ?>teacher/teacher-reset"><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 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 Teacher Id.');
|
||
|
}
|
||
|
else if(!regex.test(lemail)){
|
||
|
errArr.push('email_Sep@Str_Please enter a valid email address.');
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
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();
|
||
|
var formData = new FormData($("#loginform")[0]);
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url(); ?>Teacher/teacher_login',
|
||
|
dataType : 'json',
|
||
|
type : 'POST',
|
||
|
data : formData,
|
||
|
contentType : false,
|
||
|
processData : false,
|
||
|
success: function(response) {
|
||
|
if(response == '1'){
|
||
|
window.location.href="<?php echo base_url(); ?>Teacher/dashboard";
|
||
|
}else if(response == '0'){
|
||
|
$('#invalid_error').html("Invalid Teacher Id or Password.");
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
$('#loginform').submit(function(e){
|
||
|
e.preventDefault();
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
<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>
|