Advertisement
Guest User

Untitled

a guest
Jun 6th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     require("configuration.php");
  4.  
  5.         if(isset($_GET['login']))
  6.         {
  7.  
  8.             $username = $_POST['username'];
  9.             $password = md5(sha1(md5(sha1($_POST['password']))));
  10.  
  11.             if(!$username || !$password)
  12.             {
  13.  
  14.                 echo("All fields are required.");
  15.  
  16.             }
  17.             else
  18.             {
  19.  
  20.                 $uinfo = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");//SQL injection
  21.                 $userdata = mysql_fetch_assoc($uinfo);
  22.  
  23.                 if($userdata[password] = $password)
  24.                 {
  25.                     $_SESSION['id'] = "$userdata[id]";
  26.                     $_SESSION['password'] = "$userdata[password]";
  27.                     echo("Incorrect Username and Password!");
  28.  
  29.                 }
  30.                 else
  31.                 {
  32.                     echo("Welcome $logged[username");
  33.                 }
  34.  
  35.             }
  36.  
  37.         }
  38.         else
  39.         {
  40.             echo("<form action=\"index.php?login\" method=\"post\">
  41.            <input type=\"text\" name=\"username\" /><br />
  42.            <input type=\"password\" name=\"password\" /><br />
  43.            <input type=\"submit\" name=\"submit\" value=\"Login\" /><br />
  44.            <br /><strong>Your IP will be logged ($_SERVER[REMOTE_ADDR])</strong>
  45.            </form>");
  46.         }
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement