0% found this document useful (0 votes)
8 views

WT ASSIGNMENT

The document contains code for a simple login system consisting of three files: LOGIN46.HTML for the login form, LOGIN.PHP for processing login requests, and WELCOME.PHP for displaying a welcome message upon successful login. It uses PHP sessions to manage user authentication and displays an error message for invalid credentials. The HTML includes basic styling and structure for the login interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

WT ASSIGNMENT

The document contains code for a simple login system consisting of three files: LOGIN46.HTML for the login form, LOGIN.PHP for processing login requests, and WELCOME.PHP for displaying a welcome message upon successful login. It uses PHP sessions to manage user authentication and displays an error message for invalid credentials. The HTML includes basic styling and structure for the login interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

WT ASSIGNMENT

CODE:
LOGIN46.HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>register form</title>
</head>
<body>
<style>

.container {
width: 200px;
margin: 50px auto;
background-color: #fff;
border-radius: 5px;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
body{
background-color: brown;
}
</style>
<div class="container">
<form action="login.php" method="post">
<h1>login page</h1>
<input type="text" name="username" placeholder="Username"
required><br><br>
<input type="password" name="password" placeholder="Password"
required><br><br>
<button type="submit">Login</button>
</div>
</form>
</body>
</html>
LOGIN.PHP:
<?php
session_start();

$valid_username = "sivaraam";
$valid_password = "1234";

if($_SERVER['REQUEST_METHOD']=='post'){
$username =$_post('username');
$password =$_post('password');

if ($username === $valid_username && $password === $valid_password) {


$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
header('Location: welcome.php');
exit;
} else {
echo '<p style="color: red;">Invalid username or password.</p>';
}
}
?>

WELCOME.PHP:
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
header('Location: login.html');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Welcome</title>
</head>
<body>
<h3>Welcome, sivaraam <?php echo
htmlspecialchars($_SESSION['username']); ?>!</h3>
<p>You have successfully logged in.</p>
</body>
</html>
OUTPUT:

You might also like