Guest User

Untitled

a guest
Mar 7th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1.  
  2. <?php
  3. 1
  4. 2
  5. 3
  6. 4
  7. 5
  8. 6
  9. 7
  10. 8
  11. 9
  12. 10
  13. 11
  14. 12
  15. 13
  16. 14
  17. 15
  18. 16
  19. 17
  20. 18
  21. 19
  22. 20
  23. 21
  24. 22
  25. 23
  26. 24
  27. 25
  28. 26
  29. 27
  30. 28
  31. 29
  32. 30
  33. 31
  34. 32
  35. 33
  36. 34
  37. 35
  38. 36
  39. 37
  40. 38
  41. 39
  42. 40
  43. 41
  44. 42
  45. 43
  46. 44
  47. 45
  48. 46
  49. 47
  50. 48
  51. 49
  52. 50
  53. 51
  54. 52
  55. 53
  56. 54
  57. 55
  58. 56
  59. 57
  60. 58
  61. 59
  62. 60
  63. 61
  64. 62
  65. 63
  66. 64
  67. 65
  68. 66
  69. 67
  70. 68
  71. 69
  72. 70
  73. 71
  74. 72
  75. 73
  76. 74
  77. 75
  78. 76
  79. 77
  80. 78
  81. 79
  82. 80
  83. 81
  84. 82
  85. 83
  86. 84
  87. 85
  88. 86
  89. 87
  90. 88
  91. 89
  92. 90
  93. 91
  94. 92
  95. 93
  96. 94
  97. 95
  98. 96
  99. 97
  100. 98
  101. 99
  102. 100
  103. 101
  104. 102
  105. 103
  106. 104
  107. 105
  108. 106
  109. 107
  110. 108
  111. 109
  112. 110
  113. 111
  114. 112
  115. 113
  116. 114
  117. 115
  118. 116
  119. 117
  120. 118
  121. 119
  122. 120
  123. 121
  124. 122
  125. 123
  126. 124
  127. 125
  128. 126
  129. 127
  130. 128
  131. 129
  132. 130
  133. 131
  134. 132
  135. 133
  136. 134
  137. 135
  138. 136
  139. 137
  140. 138
  141. 139
  142. 140
  143. 141
  144. 142
  145. 143
  146. 144
  147. 145
  148. 146
  149. 147
  150. 148
  151. 149
  152. 150
  153. 151
  154. 152
  155. 153
  156. 154
  157. 155
  158. 156
  159. 157
  160. 158
  161. 159
  162. 160
  163. 161
  164. 162
  165. 163
  166. 164
  167. 165
  168. 166
  169. 167
  170. 168
  171. 169
  172. 170
  173. 171
  174. 172
  175. 173
  176. 174
  177. 175
  178. 176
  179. 177
  180. 178
  181. 179
  182. 180
  183. 181
  184. <?php
  185.  
  186. include 'config.php';
  187.  
  188. $session_username = $_SESSION['username'];
  189.  
  190. ?><html>
  191. <head><title>Login Page</title>
  192. <link href="login.css" rel="stylesheet" type="text/css" />
  193. </head>
  194. <body>
  195. <div class="wrapper">
  196. <div id="top">Online FM</div>
  197. <div id="Box1">
  198. <form action='index.php' method='POST'>
  199. Username:
  200.  
  201. <input type='text' name='username'><p />
  202. Password:
  203.  
  204. <input type='password' name='password'><p />
  205. <input type='submit' name='login' value='Log in'>
  206. </form>
  207.  
  208. <?php
  209.  
  210. if ($_POST['login'])
  211. {
  212. //get form data
  213. $username = ($_POST['username']);
  214. $password = ($_POST['password']);
  215.  
  216. if (!$username||!$password)
  217. echo "Enter a username and password";
  218. else
  219. {
  220. //log in
  221. $login = mysql_query("SELECT * FROM users WHERE username='$username'");
  222. if (mysql_num_rows($login)==0)
  223. echo "No such user";
  224.  
  225. else
  226. {
  227. while ($login_row = mysql_fetch_assoc($login))
  228. {
  229. //get database password
  230. $password_db = $login_row['password'];
  231.  
  232. //encrypt form password
  233. $password = md5($password);
  234.  
  235. //check password
  236. if ($password!=$password_db)
  237. echo "Incorrect password.";
  238. else
  239. {
  240. $_SESSION['username']=$username; //assign session
  241. header("Location: index.php"); //refresh
  242. }
  243. }
  244.  
  245.  
  246.  
  247. }
  248. }
  249. }
  250. else
  251. {
  252.  
  253. if (isset($session_username))
  254. {
  255. header('Location: me.php');
  256. }
  257.  
  258. }
  259.  
  260. ?>
  261.  
  262.  
  263. <br />Don't have an account? <a href="register.html"><b>Register one today</b></a>.</div></div>
  264. </body>
  265. </html>
  266. Position: Ln 1, Ch 1 Total: Ln 82, Ch 1497
Add Comment
Please, Sign In to add comment