Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start(); /* Starts the session */
- /* Check Login form submitted */
- if(isset($_POST['submit'])){
- /* Define username and associated password array */
- $logins = array('admin' => '123','admin1' => '123','admin3' => '123');
- /* Check and assign submitted Username and Password to new variable */
- $Username = isset($_POST['user']) ? $_POST['user'] : '';
- $Password = isset($_POST['pass']) ? $_POST['pass'] : '';
- /* Check Username and Password existence in defined array */
- if (isset($logins[$Username]) && $logins[$Username] == $Password){
- /* Success: Set session variables and redirect to Protected page */
- $_SESSION['UserData']['Username']=$logins[$Username];
- header("location:index.php");
- exit;
- } else {
- echo " Failed";
- }
- }
- ?>
- <!DOCTYPE html>
- <html class=" ">
- <!-- BEGIN BODY -->
- <body class=" login_page">
- <div>
- <div>
- <h1><a href="#" title="Login Page" tabindex="-1">Login</a></h1>
- <form action="" method="post">
- <p>
- <label for="user_login">Username<br />
- <input type="text" name="user" id="user_login" class="input" value="" size="20" /></label>
- </p>
- <p>
- <label for="user_pass">Password<br />
- <input type="password" name="pass" id="user_pass" class="input" value="" size="20" /></label>
- </p>
- <p class="submit">
- <input type="submit" name="submit" value="Sign In" />
- </p>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement