Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //session_start();
- if(isset($_POST['submit'])){
- //Vars set as if user found in dbase
- $userrow = 1;
- $custid = 3;
- $uname = $_POST['uname'];
- $email = $_POST['email'];
- if($userrow>0)
- {
- $_SESSION['user_id']=$custid;
- if(!empty($_POST['remember_checkbox'])){
- $remember_checkbox = $_POST['remember_checkbox'];
- //Set Cookie
- setcookie('username', $uname,time()+3600*24*7);
- setcookie('email', $email,time()+30);
- }else{
- //Expire the cookie
- setcookie('username', $uname,time()-3600);
- setcookie('email', $email,time()-3600);
- }
- //Redirect to dashboard
- header('Location: rememberme.php');
- }else{
- echo "Invalid Login";
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Remember Me</title>
- <link rel="stylesheet" href="./style.css">
- <link rel="icon" href="./favicon.ico" type="image/x-icon">
- <style>
- form {
- border: 3px solid #f1f1f1;
- }
- /* Full-width inputs */
- input[type=text], input[type=email] {
- width: 100%;
- padding: 12px 20px;
- margin: 8px 0;
- display: inline-block;
- border: 1px solid #ccc;
- box-sizing: border-box;
- }
- /* Set a style for all buttons */
- button {
- background-color: #04AA6D;
- color: white;
- padding: 14px 20px;
- margin: 8px 0;
- border: none;
- cursor: pointer;
- width: 100%;
- }
- /* Add a hover effect for buttons */
- button:hover {
- opacity: 0.8;
- }
- /* Extra style for the cancel button (red) */
- .cancelbtn {
- width: auto;
- padding: 10px 18px;
- background-color: #f44336;
- }
- /* Center the avatar image inside this container */
- .imgcontainer {
- text-align: center;
- margin: 24px 0 12px 0;
- }
- /* Avatar image */
- img.avatar {
- width: 40%;
- border-radius: 50%;
- }
- /* Add padding to containers */
- .container {
- padding: 40px;
- }
- /* The "Forgot password" text */
- span.psw {
- margin-left: 40%;
- padding-top: 16px;
- padding-bottom: 16px;
- }
- /* Change styles for span and cancel button on extra small screens */
- @media screen and (max-width: 300px) {
- span.psw {
- display: block;
- float: none;
- }
- .cancelbtn {
- width: 100%;
- }
- }
- </style>
- </head>
- <body>
- <main>
- <div class="container">
- <h1>Remember Me</h1>
- <?php
- print_r($_COOKIE);
- ?>
- <form action="rememberme.php" method="post" autocomplete="off">
- <div class="container">
- <label for="uname"><b>Username</b></label>
- <input type="text" placeholder="Enter Username" name="uname" value="<?php if(isset($_COOKIE['username'])){echo $_COOKIE['username'];}; ?>">
- <label for="psw"><b>Email</b></label>
- <input type="email" placeholder="Enter Your Email Address" name="email" value="<?php if(isset($_COOKIE['email'])){echo $_COOKIE['email'];}; ?>">
- <button type="submit" name="submit">Login</button>
- <label>
- <input type="checkbox" checked="checked" name="remember_checkbox"> Remember me
- </label>
- </div>
- <div class="container" style="background-color:#f1f1f1">
- <span class="psw">Forgot <a href="#">password?</a></span>
- </div>
- </form>
- </div>
- <?php
- //showSessions();
- echo '<br><br>';
- ?>
- <h1>Print_r</h1>
- <?php print_r($_COOKIE); ?>
- </main>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement