I am trying to remove spaces from username while user logged in. for example if they have username like TEST BHA (there is space between TEST AND BHA)i want that username should be TESTBHA without space and it has to take lowercase while user logged in itself.
I have found some solutions but those are not working in my condition. Can anyone help me how to resolve this issue..
Here is my username:
if (isset($_POST['signin'])) {
global $DB;
$username = str_replace(" ", "", $_POST['username']);
$password = $_POST['password'];
$sql = "SELECT * FROM {user} where username = ?";
if ($user = $DB->get_record_sql($sql, array($username))) {
//echo $user->password;
//exit;
if (password_verify($password, $user->password)) {
if ($password != 'changeme'){
if ($user->trackforums == 1) {
complete_user_login($user);
\core\session\manager::apply_concurrent_login_limit($user->id, session_id());
$userauth = get_auth_plugin($USER->auth);
$DB->set_field('user', 'firstaccess', date('YmdHis'), array('id' => $user->id));
$_SESSION['username'] = $user->username;
$_SESSION['firstname'] = $user->firstname;
$_SESSION['idnumber'] = $user->idnumber;
$_SESSION['id'] = $user->id;
$_SESSION['clientid'] = $user->clientid;
$_SESSION['maildigest'] = $user->maildigest;
$_SESSION['skype'] = $user->skype;
$_SESSION['can_access'] = true;
$_SESSION['mnethostid'] = 1;
$_SESSION['confirmed'] = 1;
if (!empty($_POST["remember"])) {
setcookie("member_login", $_POST["username"], time() + (10 * 365 * 24 * 60 * 60));
setcookie("password", $_POST["password"], time() + (10 * 365 * 24 * 60 * 60));
} else {
if (isset($_COOKIE["member_login"])) {
setcookie("member_login", "");
}
if (isset($_COOKIE["password"])) {
setcookie("password", "");
}
}
if ($user->idnumber == '3')
header('location:course.php');
elseif ($user->idnumber == '2')
header('location:course.php');
else
header('location:course.php');
}
else {
?>
<div class="alert alert-danger">
<strong> Sorry, User has been Deactivated. Contact Administrator</strong>
</div>
<?php
}
}
else {
?>
<div class="alert alert-primary">
<strong>Please change your password! By clicking this link <a style="color:red" href="forgot-password.php">Click Here</a></strong>
</div>
<?php
}
} else {
?>
<div class="alert alert-danger">
<strong> Sorry, wrong password.</strong>
</div>
<?php
}
} else {
?>
<div class="alert alert-danger">
<strong> Sorry, wrong username.</strong>
</div>
<?php
}
}