Advertisement
Guest User

Untitled

a guest
Nov 19th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. <?php
  2.  
  3. include("config.php");
  4. session_start();
  5. error_reporting(0);
  6.  
  7. $submit = $_POST['submit'];
  8. $username = sanitize($_POST['username']);
  9. $password = sanitize($_POST['password']);
  10. $password = md5($password);
  11.  
  12. if($submit)
  13. {    
  14.     if($username && $password)
  15.     {
  16.         $query = mysql_query("SELECT Name, Passwort FROM spieler WHERE Name = '$username' AND '".md5(strtoupper($password))."'");
  17.         if(mysql_num_rows($query) == 1)
  18.         {
  19.             while($row = mysql_fetch_assoc($query))
  20.             {
  21.                 $dbusername = $row['Name'];
  22.                 $dbpassword = $row['Passwort'];
  23.             }
  24.             if($username == $dbusername && $password == $dbpassword)
  25.             {
  26.                 $_SESSION['username'] = $dbusername;
  27.                 echo header('location: profile.php');
  28.             }
  29.             else echo "Wrong password!";
  30.         }
  31.         else echo "Username doesn't exist!";
  32.     }
  33.     else echo "Type name and password!";
  34. }
  35.  
  36. ?>
  37.  
  38. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  39. <html xmlns="http://www.w3.org/1999/xhtml">
  40. <head>
  41. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  42. <title>Basic UCP</title>
  43.  
  44. <form action='login.php' method='POST'>
  45. <input type="text" name="username" value='<?php echo $username?>'/>
  46. <input type="password" name="password"/>
  47. <input type='submit' name="submit" value='Login' />
  48. </form>
  49. </head>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement