untung99.homes: PHP Login
Untung99 menawarkan beragam permainan yang menarik, termasuk slot online, poker, roulette, blackjack, dan taruhan olahraga langsung. Dengan koleksi permainan yang lengkap dan terus diperbarui, pemain memiliki banyak pilihan untuk menjaga kegembiraan mereka. Selain itu, Untung99 juga menyediakan bonus dan promosi menarik yang meningkatkan peluang kemenangan dan memberikan nilai tambah kepada pemain.
Berikut adalah artikel atau berita tentang Harian untung99.homes dengan judul untung99.homes: PHP Login yang telah tayang di untung99.homes terimakasih telah menyimak. Bila ada masukan atau komplain mengenai artikel berikut silahkan hubungi email kami di koresponden@untung99.homes, Terimakasih.
Summary: in this tutorial, you’ll learn how to create a login form using a username and password.
Prerequisites
To start this tutorial, you need to complete the previous tutorial that creates a registration form.
Introduction to the PHP login form
In the previous tutorial, you learned how to create a form that allows users to register for accounts. Once the users register successfully, you redirect them to the login page so that they can use their usernames and passwords to log in.
The login page will contain a form that consists of the username and password inputs and a login button as follows:
To log in, users need to enter their username and password and click the login button.
If the username and password match, you can redirect them to a password-protected page. Otherwise, you redirect the users back to the login page with an error message:
Note that it’s more secure to issue a generic message (invalid username or password) when either username or password doesn’t match.
Create the login form
First, create the login.php
page in the public
folder.
Second, define a login form with the username and password inputs and a login button:
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://www.phptutorial.net/app/css/style.css">
<title>Logintitle>
head>
<body>
<main>
<form action="login.php" method="post">
<h1>Loginh1>
<div>
<label for="username">Username:label>
<input type="text" name="username" id="username">
div>
<div>
<label for="password">Password:label>
<input type="password" name="password" id="password">
div>
<section>
<button type="submit">Loginbutton>
<a href="register.php">Registera>
section>
form>
main>
body>
html>Code language: HTML, XML (xml)
Like the register.php
page, you can reuse the header.php
and footer.php
files from the src/inc
folder and use the view()
function to load them to the login.php
page as follows:
require __DIR__ . '/../src/bootstrap.php';
?>
view('header', ['title' => 'Login']) ?>
method="post">
="username">Username:
"text"
name="username" id="username">
“password” name=”password” id=”password”>
“register.php”>Register