Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <h1> Welcome. Please enter in a valid username and password.</h1>
- <form action="login2.php" method="post"><input type="hidden" name="ac" value="log">
- UserName: <input type="text" name="username" /> <!--Enter in valid username -->
- Password: <input type="password" name="password" /> <!--Enter in valid password -->
- <input type="submit" value="Login"/> <!--submit username and password -->
- </form>
- </body>
- </html>
- <?php
- $USERS["username1"] = "password1";
- $USERS["username2"] = "password2";
- $USERS["username3"] = "password3";
- function check_logged(){
- global $_SESSION, $USERS;
- if (!array_key_exists($_SESSION["logged"],$USERS)) {
- header("Location: login.php");
- };
- };
- ?>
- <?php
- session_start(); /// initialize session
- include("password.php");
- check_logged();
- ?>
- <html>
- <body>
- Welcome, <?php echo $_POST["username"]; ?>
- <form action="view.php" action="LINK">
- <input type="submit" value="View All Records">
- </FORM>
- </br>
- <form action="addform.php" action="LINK">
- <input type="submit" value="Add Records">
- </FORM>
- </br>
- <form action="edit.php" action="LINK">
- <input type="submit" value="Edit Records">
- </FORM>
- </br>
- <form action="delete1.php" action="LINK">
- <input type="submit" value="Delete Records">
- </FORM>
- </br>
- </body>
- </html>
- <?php
- //session_start();
- include("password.php");
- if ($_POST["ac"]=="log") { /// do after login form is submitted
- if ($USERS[$_POST["username"]]==$_POST["password"]) { /// check if submitted
- $_SESSION["logged"]=$_POST["username"];
- } else {
- echo 'Incorrect username/password. Please, try again.';
- };
- };
- if (array_key_exists($_SESSION["logged"],$USERS)) { //// check if user is logged or not
- echo "You are logged in.";//// if user is logged show a message
- echo '<form action="home.php" method="post">';
- echo '<input type="submit" value="NEXT"/>';
- } else { //// if not logged show login form
- echo '<form action="login2.php" method="post"><input type="hidden" name="ac" value="log"> ';
- echo 'Username: <input type="text" name="username" />';
- echo 'Password: <input type="password" name="password" />';
- echo '<input type="submit" value="Login" />';
- echo '</form>';
- };
- ?>
Advertisement
Add Comment
Please, Sign In to add comment