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 =...
Javascript/HTML/CSS Problem (Only use pure javascript, DO NOT USE ANY JAVASCRIPT FRAMEWORKS) Create a non-predictive T9-like...
Javascript/HTML/CSS Problem (Only use pure javascript, DO NOT USE ANY JAVASCRIPT FRAMEWORKS) Create a non-predictive T9-like keypad. For those who do not know what a T9 keypad looks like, use the following shell in an html file to get a sense of what it looked like on pre-smart cellular phones: <h3>T9 Keypad</h3> <input id="in" type="text"/> <br> <button>abc</button> <button>def</button> <br> <button>ghi</button> <button>jkl</button> <button>mno</button> <br> <button>pqrs</button> <button>tuv</button> <button>wxyz</button> <script> // your code here </script> How it functions for the assignment: * If...
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 SIMPLE HTML ,CSS(IF REQUIRED) , JAVASCRIPT(IF REQUIRED) PLEASE TELL HOW TO BRING THE EXTRA...
PLEASE WRITE SIMPLE HTML ,CSS(IF REQUIRED) , JAVASCRIPT(IF REQUIRED) PLEASE TELL HOW TO BRING THE EXTRA SCROLL BAR MENU ATTACHED WITH THE TABLE . I WANT TO BRING THE SCROLL BAR JUST ATTACHED WITH THE EXTREME END OF THE TABLE COLUMN . I DO NOT WANT THE SCROLL BAR TO APPEAR AT THE EXTREME END OF THE PAGE. Also i want the scroll bar menu to be horizontal and vertical as well. Also the table column values and all the...
Please write "my account" page program by using HTML and CSS
Please write "my account" page program by using HTML and CSS
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT