Skip to content
Snippets Groups Projects
Commit bf26f87a authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

login implementation basic

parent 63f81319
No related branches found
No related tags found
No related merge requests found
<?php
$username = $_POST['email_address'];
$password = $_POST['password'];
$result = validate_credentials($username, $password);
if ($result) {
?>
<main class="container">
<div class="bg-light p-5 rounded mt-3">
<h1>Login Success</h1>
<p class="lead">This example is a quick exercise to do basic login with html forms.</p>
</div>
</main>
<?php
} else {
?>
<main class="form-signin">
<form method="post" action="login.php">
<img class="mb-4" src="https://git.selfmade.ninja/uploads/-/system/appearance/logo/1/Logo_Dark.png" alt=""
height="50">
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
<div class="form-floating">
<input name="email_address" type="email" class="form-control" id="floatingInput"
placeholder="name@example.com">
<label for="floatingInput">Email address</label>
</div>
<div class="form-floating">
<input name="password" type="password" class="form-control" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">Password</label>
</div>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="w-100 btn btn-lg btn-primary hvr-grow-rotate" type="submit">Sign in</button>
</form>
</main>
<?php
}
<pre>
<?php
error_reporting(E_ALL & ~E_NOTICE);
$mc = new Memcached();
$mc->addServer("memcached.selfmade.ninja", 11211);
// $mc->set("foo", "Hello!");
// $mc->set("bar", "Memcached...342");
$arr = array(
$mc->get("foo"),
$mc->get("bar")
);
var_dump($arr);
var_dump($mc->getAllKeys());
?> </pre>
\ No newline at end of file
......@@ -15,8 +15,6 @@ include 'libs/load.php';
<meta name="generator" content="Hugo 0.88.1">
<title>Photogram by LAHTP</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/album/">
<!-- Bootstrap core CSS -->
<link href="/app/assets/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
......
......@@ -4,3 +4,12 @@ function load_template($name)
{
include $_SERVER['DOCUMENT_ROOT']."/app/_templates/$name.php"; //not consistant.
}
function validate_credentials($username, $password)
{
if ($username == "sibi@selfmade.ninja" and $password == "password") {
return true;
} else {
return false;
}
}
<?php
include 'libs/load.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Selfmade Ninja Academy">
<meta name="generator" content="Hugo 0.88.1">
<title>Login to Photogram</title>
<!-- Bootstrap core CSS -->
<link href="/app/assets/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hover.css/2.1.0/css/hover-min.css"
integrity="sha512-glciccPoOqr5mfDGmlJ3bpbvomZmFK+5dRARpt62nZnlKwaYZSfFpFIgUoD8ujqBw4TmPa/F3TX28OctJzoLfg=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.form-signin {
width: 100%;
max-width: 330px;
padding: 15px;
margin: auto;
}
.form-signin .checkbox {
font-weight: 400;
}
.form-signin .form-floating:focus-within {
z-index: 2;
}
.form-signin input[type="email"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
</style>
</head>
<body>
<header>
<div class="collapse bg-dark" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">Add some information about the album below, the author, or any other
background
context. Make it a few sentences long so folks can pick up some informative tidbits. Then,
link them off
to some social networking sites or contact information.</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li><a href="#" class="text-white">Follow on Twitter</a></li>
<li><a href="#" class="text-white">Like on Facebook</a></li>
<li><a href="#" class="text-white">Email me</a></li>
</ul>
</div>
</div>
</div>
</div>
<?load_template('_header');?>
</header>
<main>
<?load_template('_login');?>
</main>
<?load_template('_footer');?>
<script src="/app/assets/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
\ No newline at end of file
<pre>
<?php
$cookie_name = "testscript";
$cookie_value = $_SERVER['REQUEST_URI'];
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
// $cookie_name = "testscript";
// $cookie_value = $_SERVER['REQUEST_URI'];
// setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
print("_SERVER \n");
print_r($_SERVER);
print("_GET \n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment