Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html><head><title>Tickety</title>
- <form method="post">
- Nick: <input type="text" name="nick"><br>
- Heslo: <input type="password" name="heslo"><br>
- <input type="submit" value="Přihlásit se">
- </form>
- <?php
- $servername = "mysql.hicoria.com";
- $username = "mysql_haha";
- $password = "hahahaha";
- $dbname = "mysql_haha";
- if(isset($_POST["nick"])){
- $nick = htmlentities($_POST["nick"]);
- // Vytvorit pripojeni
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Zkontrolovat spojení
- if ($conn->connect_error) {
- die("Spojení selhalo: " . $conn->connect_error);
- }
- $result = $conn->query("SELECT * FROM authme WHERE username = '".$nick."'");
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $getUserData = $row;
- break;
- }
- $salt = explode('$', $getUserData['password'])[2];
- $hash1 = hash('sha256', $_POST["heslo"]);
- $user_password_hashed = '$SHA$'.$salt.'$'.hash('sha256', $hash1.$salt);
- if($getUserData['password'] == $user_password_hashed){
- // přihlásit - heslo sedí
- echo("Správné heslo :)");
- }else{
- echo("Špatné heslo");
- }
- } else {
- echo("Uživatel neexistuje");
- }
- $conn->close();
- }
- ?>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement