From 0deeeff32f993633e271782425a8d65cc214c8db Mon Sep 17 00:00:00 2001 From: Raghav <raghavsmart1213@gmail.com> Date: Wed, 26 Feb 2025 06:13:26 +0000 Subject: [PATCH] Added new page if Credential true with POST: Success --- _templates/login-content.php | 23 ++++++++++++++++++++++- html | 1 + libs/load.php | 8 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 120000 html diff --git a/_templates/login-content.php b/_templates/login-content.php index 34c8c43..408b99c 100644 --- a/_templates/login-content.php +++ b/_templates/login-content.php @@ -1,4 +1,22 @@ -<form action="/photogram-project-php/test.php" method="post"> +<? +// Getting the values from the form and storing them in variables. + $username = $_POST['email']; + $password = $_POST['password']; + $validate = validate_credentials($username, $password); + if($validate){?> + <!-- If it is true is display true page --> + <main class="container"> + <div class="bg-body-tertiary p-5 rounded"> + <h1>Login Success</h1> + <p class="lead">This example is a quick exercise to illustrate How to login with simple POST method</p> + <a class="btn btn-lg btn-primary" href="/docs/5.3/components/navbar/" role="button">View navbar docs »</a> + </div> + </main> + <?}else{?> + + <!-- If it is false it displays the login form --> +<main class="form-signin w-100 m-auto"> + <form action="/photogram-project-php/login.php" method="post"> <img class="mb-4 center" src="/photogram-project-php/assets/brand/devyani_logo_edit_light copy.svg" alt="" width="72" height="77"> <h1 class="h3 mb-3 fw-normal">Please sign in</h1> @@ -20,3 +38,6 @@ <button class="hvr-grow-shadow btn btn-primary w-100 py-2 " type="submit">Sign in</button> </form> +</main> +<?}?> + diff --git a/html b/html new file mode 120000 index 0000000..33abc79 --- /dev/null +++ b/html @@ -0,0 +1 @@ +/home/raghav_gr/htdocs/var/www/html \ No newline at end of file diff --git a/libs/load.php b/libs/load.php index 103993a..2dc45d2 100644 --- a/libs/load.php +++ b/libs/load.php @@ -3,4 +3,12 @@ include $_SERVER['DOCUMENT_ROOT']. "/photogram-project-php/_templates/$name.php"; } + + function validate_credentials($username, $password){ + if($username == "raghav@gmail.com" and $password == "raghav"){ + return true; + }else{ + return false; + } + } ?> \ No newline at end of file -- GitLab