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
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.
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 =...
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...
Please write "my account" page program by using HTML and CSS
Please write "my account" page program by using HTML and CSS
Make sure it works on jsfiddle and keep the code seperate html: css: javascript: -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Make sure it works on jsfiddle and keep the code seperate html: css: javascript: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Assignment You should already have some experience with jQuery and some simple experience with JSON (from charting). In this assignment we will be creating some JSON data, parsing it, and displaying it. Step 1 – If you are not familiar with JSON you should complete the JSON tutorial at w3schools Step 2- You will now create a JSON file to represent some data of your...
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...
Use HTML&CSS& JavaScript to: 3-4) Write a JQuery Ajax program which can communicate with flicker to...
Use HTML&CSS& JavaScript to: 3-4) Write a JQuery Ajax program which can communicate with flicker to get the last pictures taken from any place or related to any concept(s) the user has written in a textbox, say Sydney, train. Some information associated with the image like its topic, time taken, and its link needs to be appeared with it. 3-5) Develop a server which can serve the file you developed in 3-4. 3-6) Add a plugin to the real jQuery...
Write the below code to use HTML and JavaScript. 1. a) Write a JavaScript program to...
Write the below code to use HTML and JavaScript. 1. a) Write a JavaScript program to display the current day and time. b) Write a JavaScript program to print the contents of the current window.   c) Write a JavaScript program where the program takes a random integer between 1 to 10 d) Write a JavaScript program to calculate multiplication and division of two numbers (input from the user). e)Write a JavaScript program to create a new string from a given...
suggests on how to save the web portfolio Programming languages Chosen: HTML, CSS, and JavaScript. Project...
suggests on how to save the web portfolio Programming languages Chosen: HTML, CSS, and JavaScript. Project Name: Auto Portfolio Project Goal: Create a website that will generate a web portfolio using information inputted by the user. Product Backlog using user stories: As a user, I want to be able to save my web portfolio in a format which I can save so I can use the website later for my own needs. Example: http://www-personal.umich.edu/~hamatilo/
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT