Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
myprogrammingblog.com/UI Components/Login_form_with_Bootstrap_PHP/index.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
83 lines (52 sloc)
2.47 KB
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
<?php | |
$LoginError =""; | |
if (isset($_POST["submit"])) | |
{ | |
$email = $_POST['email']; | |
$name = $_POST['password']; | |
$errEmail = false; | |
$errPassword = false; | |
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { | |
$errEmailMessage = "Please Enter a Valid Email."; | |
} | |
if (!$_POST['password'] || strlen($_POST['password']) < 8 ) { | |
$errPassMessage = "Password should be minimum 8 characters."; | |
} | |
if (isset($errEmailMessage) || isset($errPassMessage) ) | |
{ | |
$loginMessage= '<div class="container"><div class="alert alert-danger">Sorry there were errors loging into your account.Please try again later.</div></div>'; | |
} | |
else | |
{ | |
$loginMessage= '<div class="alert alert-success">You have successfully logged into your account.</div>'; | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>PHP/Bootstrap Login Form</title> | |
<!-- Bootstrap core CSS --> | |
<link href="css/bootstrap.css" rel="stylesheet"> | |
<!-- Custom styles for this template --> | |
<link href="css/style.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="container"> | |
<form class="form-signin" method="post" action="index.php"> | |
<?php if (isset($loginMessage)) echo $loginMessage ; ?> | |
<h2 class="text-center">Please Login</h2> | |
<label for="inputEmail" class="sr-only">Email address</label> | |
<input type="text" id="inputEmail" name="email" class="form-control" placeholder="Email address" required autofocus> | |
<span class="text-danger"><?php if (isset($errEmailMessage)) echo $errEmailMessage; ?></span> | |
<label for="inputPassword" class="sr-only">Password</label> | |
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required> | |
<span class="text-danger"><?php if (isset($errPassMessage)) echo $errPassMessage; ?></span> | |
<button name="submit" class="btn btn-success btn-block" type="submit">Login</button> | |
</form> | |
</div> <!-- /container --> | |
<script src="js/bootstrap.js"></script> | |
</body> | |
</html> |