Guest User

Untitled

a guest
Mar 25th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2. if(isset($_SESSION['authentication'])){?>
  3. <script type="text/javascript">
  4. <!--
  5. window.location = "main.php"
  6. //-->
  7. </script>
  8. You're already logged in, redirecting you.
  9. <?php }else{
  10.  
  11. if(isset($_POST['login'])){
  12.  
  13. $postedUsername = $_POST['username']; //Gets the posted username, put's it into a variable.
  14. $postedPassword = $_POST['password']; //Gets the posted password, put's it into a variable.
  15. $userDatabaseSelect = $m->thundergallery->users; //Selects the user collection
  16. $userDatabaseFind = $userDatabaseSelect->find(array('username' => $postedUsername)); //Does a search for Usernames with the posted Username Variable
  17.  
  18. //Iterates through the found results
  19. foreach($userDatabaseFind as $userFind) {
  20. $storedUsername = $userFind['username'];
  21. $storedPassword = $userFind['password'];
  22. }
  23.  
  24. if($postedUsername == $storedUsername && $postedPassword == $storedPassword){
  25. $_SESSION['authentication'] = 1;
  26. ?>
  27.  
  28. <script type="text/javascript">
  29. <!--
  30. window.location = "main.php"
  31. //-->
  32. </script> <?php
  33.  
  34. }else{
  35.  
  36. $wrongflag = 1;
  37. }
  38.  
  39. }else{}
  40. ?>
  41.  
  42. <div class='login'>
  43. <form action='login.php' method='post'>
  44. <br/> You're not logged in as an admin, please do so. <br/><br/>
  45. <?php if($wrongflag == 1){ echo "<font size='2px' color='red' face='Arial'> Wrong Username/Password </font><br/>";} ?>
  46. <input class='login-text' type='text' name='username' value='Username' onFocus="if(this.value == 'Username') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Username';}">
  47. <input class='login-text' type='password' name='password' value='Password' onFocus="if(this.value == 'Password') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Password';}">
  48. <input class='login-button' type='submit' name='login' value='Login'>
  49. </form>
Add Comment
Please, Sign In to add comment