Guest User

Untitled

a guest
Jun 7th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2.     if (!isset($_REQUEST['username']))
  3.     {
  4.         include 'form.html.php';
  5.     }
  6.     else
  7.     {
  8.         $username = $_REQUEST['username'];
  9.         $password = $_REQUEST['password'];
  10.         $link = mysqli_connect('localhost', 'root', 'youaintgettinmypasswordson');
  11.         if (!$link)
  12.         {
  13.             $output = "Unable to connect to the database server.";
  14.             include "output.html.php";
  15.             exit();
  16.         }
  17.         if (!mysqli_set_charset($link, 'utf8'))
  18.         {
  19.             $output = "Unable to set database connection encoding.";
  20.             include "output.html.php";
  21.             exit();
  22.         }
  23.         if (!mysqli_select_db($link, 'users'))
  24.         {
  25.             $output = "Unable to locate the users.";
  26.             include "output.html.php";
  27.             exit();
  28.         }
  29.         $sql = 'SELECT * FROM users_table WHERE username LIKE "' . $username . '" AND password LIKE MD5("' . $password . '");';
  30.         if (!($result=mysqli_query($link, $sql)))
  31.         {
  32.             $output = "Error querying user database: " . mysqli_error($link);
  33.             include "output.html.php";
  34.             exit();
  35.         }
  36.         if (($row = mysqli_fetch_array($result))==NULL)
  37.         {
  38.             echo "User does not exist, or password incorrect!<br>";
  39.             include 'form.html.php';
  40.         }
  41.         else
  42.         {
  43.             echo "Welcome " . $row['username'] . "!!";
  44.         }
  45.        
  46.     }
  47. ?>
Add Comment
Please, Sign In to add comment