Question

In: Computer Science

Write a log-in log-out session using PHP, CSS, and HTML only. NO MYSQL and JavaScript allowed....

Write a log-in log-out session using PHP, CSS, and HTML only. NO MYSQL and JavaScript allowed.

1. Need an HTML form and a login form; separate file.

2. need a CSS file to make it look good

3. Must store visitors' info in a .txt file and validate from there if the user exists before granting access to the dashboard. If the user does not exist, render the form to signup. If the user exists take them to their dashboard. Just write granted access to the dashboard and no need to do anything else.

4. All the pages must have the same theme(looking same in the background using CSS)

Solutions

Expert Solution

Step:1

We Have To Create Some required Files For Our Login System .

Files are :-Create all files and put together in same folder

  • Index.php //Show Dashboard After Successful Login.
  • User.txt // hold UserName | Password | email | CompanyName
  • Style.php //Conatin Style For Pages
  • login.php //Login Form
  • logout.php //Code For Destroy Login Session.
  • auth.php // Code for Authentication

Now I am Putting Code For All files:

CODE FOR index.php


<?php 

session_start();
include "style.php";
if (!isset($_SESSION['Loggedin'])) {
  header('Location: login.php');
  exit;
}
?>
<!DOCTYPE html>
<html>
<head>
        <title>DashBoard</title>
</head>
<body>
<section>
        <div>
                <h1>Dash Board-Logged IN</h1>
        <p><?php echo $_SESSION['email']."<br>". $_SESSION['company'] ; ?></p>
        <form action="logout.php" method="post">
                <input type="submit" name="Logout" value="logout">
        </form> 
        </div>
</section>
</body>
</html>

CODE FOR login.php

<?php include "style.php";?>

<!DOCTYPE html>
<html>
<head>
        <title>Login</title>
</head>
<body>
<section>
        <div>
                <h1>Login</h1>
                <form action="auth.php" method="POST">
                Username: <input type="text" name="username" required="">
                <br />
                Password: <input type="password" name="pass" required="">
                <br />
                <input type="submit" name="submitlogin" value="Login">
        </form>
        </div>
</section>
</body>
</html>

CODE FOR auth.php

<?php 
session_start();
$userN = $_POST['username'];
$passW = $_POST['pass'];
$userlist = file ('user.txt');


$_SESSION['Loggedin'] = false;
foreach ($userlist as $user) {
    $user_details = explode('|', $user);
    if ($user_details[0] == $userN && $user_details[1] == $passW) {
        $_SESSION['Loggedin'] = TRUE;
         $_SESSION['email'] = $user_details[2];
        $_SESSION['company'] = $user_details[3];

        break;
    }
}

if ($_SESSION['Loggedin'])
 {
     header('Location: index.php');
} else {
    echo "<br> You have entered the wrong username or password. Please try again. <br><a href='login.php'>Goto Login</a>";
}
?>

CODE FOR logout.php

<?php
session_start();
session_destroy();
// Redirect to the login page:
header('Location: index.php');
?>

user.txt

pete|petepass|[email protected]|Pete Enterprizes
john|johnpass|[email protected]|John Corporation

Related Solutions

write php code for buying and selling web using sql, javascript ,html ,css style
write php code for buying and selling web using sql, javascript ,html ,css style
Task 1: HTML and CSS Create a website using HTML5 and CSS3 only. Please no JavaScript...
Task 1: HTML and CSS Create a website using HTML5 and CSS3 only. Please no JavaScript or Bootstrap. Website theme can be anything you want: a country, a town, a place, a hobby, people (yourself, your family...), pets, flowers, food, or anything that you find interesting or useful. It may be about real people/places/things or fictitious. Part 1: Content (HTML) After you decide the theme of your website, create HTML pages with the content you want to present. Remember to...
Build an application using HTML, CSS, javascript, json. It is not necessary for backend to be...
Build an application using HTML, CSS, javascript, json. It is not necessary for backend to be working but the frontend should be good. App should to simple and useful in our day to day life. For eg- grocery shopping list or alarm or weather forecast or reminder.
Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following HTML...
Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following HTML tags to design your webpage: <h1>...</h1>,<h3>...</h3>, <h6>...</h6>, <p>...</p>, <b>...</b>, <i>...</i>, <a>...</a>, <img...>, <table>... </table>, <div>...</div>, <form>...</form>, <input type="text">, and <input type= "submit"> Use an external css to change the default style of your webpage. You must use at least one element selector, one id selector, and one class selector Using text input and submit button, allow the user to change the background color of...
JS Bin / Tax Calculator / using HTML | CSS | JavaScript ------------------------------------------------------------------------------------------- How can I...
JS Bin / Tax Calculator / using HTML | CSS | JavaScript ------------------------------------------------------------------------------------------- How can I edit the JavaScript below so that when the calculate button is clicked the total price only shows two decimal places by using the toFixed() method? ----------------------------------------------------------------------------------------------------------- JavaScript: // Variables var tax = "tax"; // Tax percentage var taxRate = document.getElementById('tax'); // Selecting tax element // On the time of loading the DOM we are setting the tax rate window.addEventListener('DOMContentLoaded', (event) => { taxRate.value =...
Write a simple PHP script. In your script use all of the following: HTML, Javascript, and...
Write a simple PHP script. In your script use all of the following: HTML, Javascript, and PHP.
Use PHP, javascript and a little bit of Html More focus on php Create a logout...
Use PHP, javascript and a little bit of Html More focus on php Create a logout page (for patients) in hotel management. Please provide the screenshot of the output too (logout page). Hint: the logout page should include like this thanks for visting etcetera. Thanks in advance
Please write "my account" page program by using HTML and CSS
Please write "my account" page program by using HTML and CSS
For this assignment, you will write a tic-tac-toe application in HTML and JavaScript, using an HTML...
For this assignment, you will write a tic-tac-toe application in HTML and JavaScript, using an HTML <canvas> tag. The game will be played "hot seat" where players take turns using the same device. Requirements: The canvas should be 600px tall and wide, with the gameplay area occupying most of the canvas. The X's and O's may be drawn using polygons or large-font text The grid should be drawn using polygons, specifically long, thin rectangles Before & between games, the canvas...
PHP, JAVASCRIPT, MYSQL below is what I have. Can fill in the details for the database...
PHP, JAVASCRIPT, MYSQL below is what I have. Can fill in the details for the database 5. “Login to DB”, “Logout DB”, sub-menus of “File” 5.1 _____ When the user selects “Login to DB”, a window should popup asking the user to enter login and password. Your program should verify the login and password against the DV_User table in the datamining database. A corresponding message should be shown in the message area when the login failed or successful. If it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT