Advertisement
Guest User

Untitled

a guest
Apr 9th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. <?php
  2. require_once("/_php_includes/_PHP_Header.inc.php");
  3. $pagina = 'Autentificare';
  4. if(isset($_SESSION['username']))
  5. {
  6. Header("Location: ".$php['HTTP_HOST']."");
  7. return 1;
  8. }
  9. if(isset($_POST['login']))
  10. {
  11. $salt = '78sdjs86d2h';
  12. $username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
  13. $password = mysqli_real_escape_string($DB_H, addslashes($_POST['password']));
  14. $hash1 = hash('sha256', $password . $salt);
  15. $hash = strtoupper($hash1);
  16.  
  17.  
  18. $dbh = new PDO("mysql:host=localhost;dbname=server", "root", "");
  19.  
  20. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  21.  
  22. $stmt = $dbh->prepare("SELECT id, Name, password FROM players
  23. WHERE Name = :numele AND password = :parola");
  24.  
  25. /*** bind the parameters ***/
  26. $stmt->bindParam(':numele', $username, PDO::PARAM_STR);
  27. $stmt->bindParam(':parola', $hash, PDO::PARAM_STR, 40);
  28.  
  29. /*** execute the prepared statement ***/
  30. $stmt->execute();
  31.  
  32. /*** check for a result ***/
  33. $user_id = $stmt->fetchColumn();
  34.  
  35. /*** if we have no result then fail boat ***/
  36. if($user_id == false)
  37. {
  38. $msg = "Parola introdusă de tine este greșită!";
  39. }
  40. /*** if we do have a result, all is well ***/
  41. else
  42. {
  43. /*** set the session user_id variable ***/
  44. $_SESSION['username'] = $username;
  45. $_SESSION['password'] = $hash;
  46.  
  47. echo "
  48. <script type='text/javascript'>
  49. <!--
  50. function Redirect()
  51. {
  52. window.location='/panel/';
  53. }
  54. setTimeout('Redirect()', 50);
  55. //-->
  56. </script>";
  57. }
  58. }
  59.  
  60. ?>
  61. <?php
  62. $getx = mysqli_query($DB_H, "SELECT * FROM news order by time DESC LIMIT 1");
  63. while($row2 = mysqli_fetch_array($getx)) { ?>
  64. <?php } ?>
  65. <div class="breadcrumbs" id="breadcrumbs">
  66. <script type="text/javascript">
  67. try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
  68. </script>
  69. <ul class="breadcrumb">
  70. <li>
  71. <i class="icon-home home-icon"></i>
  72. <a href="index">ETD</a>
  73. </li>
  74. <li class="active"><i class="icon-angle-right"></i>
  75. <?php echo htmlspecialchars($pagina);?>
  76. </li>
  77. </ul>
  78. <div class="nav-search" id="nav-search">
  79. <form class="form-search" action="search.php">
  80. <span class="input-icon">
  81. <input type="text" placeholder="Caută un jucător.." name="name" class="nav-search-input" autocomplete="off">
  82. <i class="icon-search nav-search-icon"></i>
  83. </span>
  84. </form>
  85. </div>
  86. </div>
  87.  
  88.  
  89. <div class="page-content">
  90. <div class="row-fluid">
  91.  
  92.  
  93. <center>
  94. <h3>Autentificare</h3>
  95.  
  96. <?php if(isset($msg)): ?>
  97. <h5><font color="red"><?= $msg ?></font></h5>
  98. <?php endif; ?>
  99. <hr>
  100.  
  101.  
  102. <form method="post" action="">
  103.  
  104. <p>Numele tău din joc:</p>
  105.  
  106. <input type="text" name="username">
  107.  
  108. <p>Parola folosită la inregistrare:</p>
  109.  
  110. <input type="password" name="password" value ="">
  111. <br>
  112. <button type="submit" name="login" class="btn btn-primary">Autentificare</button>
  113. <a type="submit" href ="recover.php" value="Recuperare" class="btn btn-primary">Recuperare</a>
  114.  
  115. </form>
  116.  
  117. <br><br>
  118.  
  119. </center>
  120.  
  121.  
  122. </div>
  123. </div>
  124. <?php require_once("/_php_includes/_PHP_Footer.inc.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement