Advertisement
Guest User

Untitled

a guest
Jul 18th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. // INDEX.PHP
  2. <?php
  3. session_start();
  4. if(isset($_SESSION['user'])){
  5. header('Location: panel.php');
  6. }
  7. ?>
  8. <!doctype html>
  9. <html>
  10. <head>
  11. <meta charset="utf-8"/>
  12. <title>ALPHAMMO</title>
  13. <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,800' rel='stylesheet' type='text/css'>
  14. <link href="css/Loginbootstrap.min.css" rel="stylesheet">
  15. <style type="text/css">
  16. body {
  17. color: #5e6d81;
  18. background: #eaedf1;
  19. }
  20. input[type="text"], input[type="password"] {
  21. font-family: 'Open Sans', sans-serif;
  22. font-size: 18px;
  23. padding: 16px 0 16px 10px;
  24. background: #fff;
  25. border: 0;
  26. box-shadow: none;
  27. width: 77%;
  28. outline: none;
  29. }
  30. input[type="submit"] {
  31. font-family: 'Open Sans', sans-serif;
  32. font-size: 20px;
  33. margin: 10px 0 0 0;
  34. padding: 16px 0;
  35. width: 100%;
  36. color: #fff;
  37. background: #ff3333;
  38. border: 0;
  39. border-radius: 4px;
  40. }
  41. input[type="submit"]:hover {
  42. background: #ff4433;
  43. }
  44. input[type="text"]::-webkit-input-placeholder, input[type="password"]::-webkit-input-placeholder {
  45. color: #dbe1e8;
  46. }
  47. input[type="text"]:-moz-placeholder, input[type="password"]:-moz-placeholder {
  48. color: #dbe1e8;
  49. }
  50. input[type="text"]::-moz-placeholder, input[type="password"]::-moz-placeholder {
  51. color: #dbe1e8;
  52. }
  53.  
  54. .login {
  55. width: 300px;
  56. margin: 100px auto;
  57. }
  58. .input-prepend {
  59. width: 100%;
  60. margin: 0 0 10px 0;
  61. }
  62. .input-prepend .add-on {
  63. color: #5e6d81;
  64. font-size: 18px;
  65. font-weight: bold;
  66. width: 20%;
  67. padding: 16px 0;
  68. background: #9ea7b3;
  69. border: 0;
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <div class="login">
  75. <?php
  76. if($error == 1){
  77. echo '<p class="alert alert-danger">ACESSO NEGADO!</p>';
  78. }else if($error == 2){
  79. echo '<p class="alert alert-danger">ÁREA RESTRITA</p>';
  80. }else if($error == 3){
  81. echo '<p class="alert alert-warning">DESLOGADO!</p>';
  82. }
  83. ?>
  84. <form method="post" action="processLogin.php">
  85. <div class="input-prepend">
  86. <span class="add-on"><img src="img/user.png" /></span>
  87. <input class="" id="prependedUsername" type="text" placeholder="E-Mail" name="user">
  88. </div>
  89. <div class="input-prepend">
  90. <span class="add-on"><img src="img/lock.png" /></span>
  91. <input class="" id="prependedPassword" type="password" placeholder="Senha" name="pass">
  92. </div>
  93. <div class="controls">
  94. <input type="submit" value="Entrar" />
  95. </div>
  96. </form>
  97. </div>
  98. </body>
  99. </html>
  100.  
  101.  
  102.  
  103. // PROCESS LOGIN.PHP
  104.  
  105. <?php
  106. //Inclusão das classes.
  107. require_once('class/init.php');
  108. session_start();
  109.  
  110. //Conexão com base de dados.
  111. $pdo = openConnection();
  112.  
  113. $user = $_POST['user'];
  114. $pass = $_POST['pass'];
  115. $pass = md5('g5sc4gs1fz0h'.$pass);
  116.  
  117. //Autentica o usuário
  118. $auth = new Authentication($pdo);
  119. if($auth->authUser($user, $pass)){
  120. header('Location: panel.php');
  121. }else{
  122. header('Location: index.php?error=1');
  123. };
  124. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement