-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
118 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,23 @@ | |
$login= false; | ||
$showError = false; | ||
$showalert = false; | ||
session_start(); | ||
|
||
if (isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == true){ | ||
header("location: home.php"); | ||
} | ||
|
||
|
||
if ($_SERVER["REQUEST_METHOD"]=="POST"){ | ||
include 'partials/_dbconnect.php'; | ||
$email = $_POST["email"]; | ||
$password = $_POST["password"]; | ||
// Password complexity pattern (at least one lowercase, one uppercase, one digit, one special char, and minimum 8 characters) | ||
$pattern = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/'; | ||
|
||
//to check if the password/ email is blank | ||
if($email == '' || $password == ''){ | ||
$showError = "Enter valid Email/password"; | ||
} | ||
elseif (!preg_match($pattern, $password)) { | ||
$showError = "Password must be at least 8 characters long, include at least one uppercase letter, one lowercase letter, one digit, and one special character."; | ||
} | ||
//if not blank then go to else | ||
//if not blank then go to else | ||
else { | ||
$sql = "select * FROM users where email = '$email'"; | ||
$result = mysqli_query($conn, $sql); | ||
|
@@ -156,10 +157,12 @@ | |
<div class="login-signup-form__input-group login-signup-form__input-group--full"> | ||
<input type="email" class="login-signup-form__input" id="email" name="email" placeholder="[email protected]"> | ||
</div> | ||
<div class="login-signup-form__input-group login-signup-form__input-group--full"> | ||
<input type="password" class="login-signup-form__input" name="password" id="password" placeholder="......."> | ||
</div> | ||
|
||
<div class="login-signup-form__input-group"> | ||
<div class="login-signup-form__input" onclick="document.getElementById('password').focus()"> | ||
<input type="password" name="password" class="login-signup-form__inputfield" id="password" placeholder="......."> | ||
<i class="bi bi-eye-fill eye-open" id="eye-btn-p"></i> | ||
</div> | ||
</div> | ||
<button class="login-signup-form__submit u-margin-top-large" type="submit" id="submit-login">Sign In</button> | ||
</form> | ||
</div> | ||
|
@@ -174,6 +177,25 @@ | |
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
<script> | ||
const eyeBtnPassword =document.getElementById("eye-btn-p"); | ||
const eyeBtnConfirmPassword =document.getElementById("eye-btn-cp"); | ||
const passwordField =document.getElementById("password"); | ||
const confirmPasswordField =document.getElementById("cpassword"); | ||
|
||
eyeBtnPassword.addEventListener('click', ()=>{ | ||
let attr =passwordField.getAttribute('type') | ||
if(attr == "password"){ | ||
passwordField.setAttribute('type','text'); | ||
eyeBtnPassword.classList.remove("bi-eye-fill") | ||
eyeBtnPassword.classList.add("bi-eye-slash-fill") | ||
}else{ | ||
passwordField.setAttribute('type','password'); | ||
eyeBtnPassword.classList.add("bi-eye-fill") | ||
eyeBtnPassword.classList.remove("bi-eye-slash-fill") | ||
} | ||
}) | ||
</script> | ||
</body> | ||
</html> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ | |
use PHPMailer\PHPMailer\SMTP; | ||
use PHPMailer\PHPMailer\Exception; | ||
|
||
session_start(); | ||
|
||
if (isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == true){ | ||
header("location: home.php"); | ||
} | ||
|
||
|
||
$showAlert = false; | ||
|
@@ -16,13 +20,19 @@ | |
$email= $_POST["email"]; | ||
|
||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) { | ||
// Password complexity pattern (at least one lowercase, one uppercase, one digit, one special char, and minimum 8 characters) | ||
$pattern = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/'; | ||
|
||
$password = $_POST["password"]; | ||
$cpassword = $_POST["cpassword"]; | ||
|
||
if ($email == '' || $password == '') { | ||
$showError = "Enter valid Email/password"; | ||
} | ||
// Preg_match for the password pattern | ||
elseif (!preg_match($pattern, $password)) { | ||
$showError = "Password must be at least 8 characters long, include at least one uppercase letter, one lowercase letter, one digit, and one special character."; | ||
} | ||
else{ | ||
$existSql = "SELECT * FROM `users` WHERE email = '$email' "; | ||
$result = mysqli_query($conn, $existSql); | ||
|
@@ -190,11 +200,16 @@ class="btn btn-dark me-2">Login</button></a> | |
<input type="email" name="email" class="login-signup-form__input" id="email-id" placeholder="[email protected]"> | ||
|
||
</div> | ||
<div class="login-signup-form__input-group login-signup-form__input-group--half"> | ||
<input type="password" name="password" class="login-signup-form__input" id="password" placeholder="......."> | ||
<input type="password" name="cpassword" class="login-signup-form__input" id="password" placeholder="......."> | ||
<div class="login-signup-form__input-group"> | ||
<div class="login-signup-form__input" onclick="document.getElementById('password').focus()"> | ||
<input type="password" name="password" class="login-signup-form__inputfield" id="password" placeholder="......."> | ||
<i class="bi bi-eye-fill eye-open" id="eye-btn-p"></i> | ||
</div> | ||
<div class="login-signup-form__input" onclick="document.getElementById('cpassword').focus()"> | ||
<input type="password" name="cpassword" class="login-signup-form__inputfield" id="cpassword" placeholder="......."> | ||
<i class="bi bi-eye-fill eye-open" id="eye-btn-cp"></i> | ||
</div> | ||
</div> | ||
|
||
<button class="login-signup-form__submit u-margin-top-extra-large" type="submit" id="submit-login">Sign Up</button> | ||
</form> | ||
</div> | ||
|
@@ -223,7 +238,38 @@ class="btn btn-dark me-2">Login</button></a> | |
</div> | ||
</section> | ||
|
||
|
||
<script> | ||
const eyeBtnPassword =document.getElementById("eye-btn-p"); | ||
const eyeBtnConfirmPassword =document.getElementById("eye-btn-cp"); | ||
const passwordField =document.getElementById("password"); | ||
const confirmPasswordField =document.getElementById("cpassword"); | ||
|
||
eyeBtnPassword.addEventListener('click', ()=>{ | ||
let attr =passwordField.getAttribute('type') | ||
if(attr == "password"){ | ||
passwordField.setAttribute('type','text'); | ||
eyeBtnPassword.classList.remove("bi-eye-fill") | ||
eyeBtnPassword.classList.add("bi-eye-slash-fill") | ||
}else{ | ||
passwordField.setAttribute('type','password'); | ||
eyeBtnPassword.classList.add("bi-eye-fill") | ||
eyeBtnPassword.classList.remove("bi-eye-slash-fill") | ||
} | ||
}) | ||
|
||
eyeBtnConfirmPassword.addEventListener('click', ()=>{ | ||
let attr =confirmPasswordField.getAttribute('type') | ||
if(attr == "password"){ | ||
confirmPasswordField.setAttribute('type','text'); | ||
eyeBtnConfirmPassword.classList.remove("bi-eye-fill") | ||
eyeBtnConfirmPassword.classList.add("bi-eye-slash-fill") | ||
}else{ | ||
confirmPasswordField.setAttribute('type','password'); | ||
eyeBtnConfirmPassword.classList.add("bi-eye-fill") | ||
eyeBtnConfirmPassword.classList.remove("bi-eye-slash-fill") | ||
} | ||
}) | ||
</script> | ||
|
||
</body> | ||
|
||
|