Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?php require_once("../_php_includes/_PHP_Conf.inc.php");
  2.  
  3. if(isset($_SESSION['username']) && isset($_SESSION['password'])){
  4. Header("Location: ".$php['HTTP_HOST']."/pages/home");
  5. return 1;
  6. }
  7. if(isset($_POST['login']))
  8. {
  9. $salt = '78sdjs86d2h';
  10. $username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
  11. $password = mysqli_real_escape_string($DB_H, addslashes($_POST['password']));
  12. $hash1 = hash('sha256', $password . $salt);
  13. $hash = strtoupper($hash1);
  14.  
  15.  
  16. $dbh = new PDO("mysql:host=localhost;dbname=zp_hid12129", "root", "");
  17.  
  18. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  19.  
  20. $stmt = $dbh->prepare("SELECT id, name, password FROM users
  21. WHERE name = :numele AND password = :parola");
  22.  
  23. /*** bind the parameters ***/
  24. $stmt->bindParam(':numele', $username, PDO::PARAM_STR);
  25. $stmt->bindParam(':parola', $password, PDO::PARAM_STR, 40);
  26.  
  27. /*** execute the prepared statement ***/
  28. $stmt->execute();
  29.  
  30. /*** check for a result ***/
  31. $user_id = $stmt->fetchColumn();
  32.  
  33. /*** if we have no result then fail boat ***/
  34. if($user_id == false)
  35. {
  36. $msg = "Datele introduse sunt greșite!";
  37. }
  38. /*** if we do have a result, all is well ***/
  39. else
  40. {
  41. /*** set the session user_id variable ***/
  42. $_SESSION['username'] = $username;
  43. $_SESSION['password'] = $password;
  44.  
  45. echo "
  46. <script type='text/javascript'>
  47. <!--
  48. function Redirect()
  49. {
  50. window.location='/panel/';
  51. }
  52. setTimeout('Redirect()', 50);
  53. //-->
  54. </script>";
  55. }
  56. }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement