Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2. $my_loginName = "comp321";
  3. $my_password = "comp321_0910";
  4. $expire_period = time()+60*60;
  5. $login_success = false;
  6. if(isset($_POST['loginName'])){
  7. $loginName = $_POST['loginName'];
  8. $password = $_POST['password'];
  9. setcookie("login_success", false, $expire_period);
  10. if($loginName == $my_loginName && $password == $my_password){
  11. $login_success = true;
  12. setcookie("login_success", true, $expire_period);
  13. setcookie("login_time", date(DATE_COOKIE), $expire_period);
  14. header( "Location:".$_SERVER['PHP_SELF'] );
  15. exit();
  16. }
  17. }
  18. if(isset($_GET['logout'])){
  19. setcookie("login_success", '', time()-3600);
  20. setcookie("login_time", '', time()-3600);
  21. header( "Location:".$_SERVER['PHP_SELF'] );
  22. exit();
  23. }
  24. ?>
  25. <html>
  26. <body>
  27. <?php
  28. if(isset($_COOKIE['login_success'])){
  29. ?>
  30. You are already logged in successfully. <br>
  31. <?php
  32. }else{
  33. ?>
  34. <h1 align="center">321 shopping center</h1>
  35. <image src="">
  36. <form name="frm_login" method="POST" action="store.php">
  37. <table align="center" width="300" border="0" cellspacing="5" cellpadding="5">
  38. <tr>
  39. <td>Username : </td>
  40. <td><input name="loginName" id="loginName" type="text"></td>
  41. </tr>
  42. <tr>
  43. <td>Password : </td>
  44. <td><input name="password" id="password" type="password"></td>
  45. </tr>
  46. <tr>
  47. <td>&nbsp;</td>
  48. <td><input type="submit" value="Login">
  49. <a href="registration.php">New user</a></td>
  50. </tr>
  51. </table>
  52. </form>
  53. <?php
  54. if($login_success == false && isset($_POST['loginName'])){
  55. ?>
  56. <font color="#FF0000">
  57. <b>username or password incorrect!</b></font><br><br>
  58. <?php
  59. }
  60. }
  61. ?>
  62. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement