Advertisement
Lukshio

Untitled

Jun 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. $salt  = $randomString;
  3.     function generateRandomString ($length = 16) {
  4.     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  5.     $charactersLength = strlen($characters);
  6.     $randomString = '';
  7.     for ($i = 0; $i < $length; $i++) {
  8.         $randomString .= $characters[rand(0, $charactersLength - 1)];
  9.     }
  10.     return $randomString;
  11.     $username = $_POST['user'];
  12.     $password = $_POST['pass'];
  13.     $password = "$2y$10$" + $salt + "$" + password_hash($password, PASSWORD_BCRYPT + $salt) ;
  14. //  $password = password_hash($password, PASSWORD_BCRYPT);
  15.    
  16.     $conn = mysqli_connect("uvdb36.active24.cz", "ipeocz", "0vWC0orWOM");
  17.    
  18.     $username = stripslashes($username);
  19.     $password = stripcslashes($password);
  20.     $username = mysqli_real_escape_string($conn, $username);
  21.   //  $password = mysqli_real_escape_string($conn, $password);
  22.    
  23.    
  24.     mysqli_select_db($conn, "ipeocz");
  25.    
  26.     if  ($result = mysqli_query($conn, "select * from AuthMe where realname = '$username' and password = '$password'")){
  27.         $_SESSION['username'] = $username;
  28.         echo "session started";}
  29.    
  30.         else { ("Failed to query database".mysqli_error($conn));
  31.         echo "Zadejte prosim znovu vase udaje";}
  32.                
  33.  //   $row = mysqli_fetch_array($result) ;
  34.     echo $password;
  35.   /*  if ($row['realname'] == $username && $row['password'] == $password){
  36.         echo "Uspesne prihlaseni! Vitej ".$row['realname'];
  37.         $_SESSION['username'] = $username;
  38.        
  39.     }else{
  40.         echo "Zadejte prosim znovu vase udaje";
  41.       //  header("Location: http://localhost/IPeo/login.php");
  42.     } */
  43.        
  44.     if (isset($_SESSION['username'])){
  45.         echo ("<a href='index.html?action=logout'>Logout</a>");
  46.         session_unset();
  47.     }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement