Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <?php
  2.   $servername = "localhost";  //replace your servername
  3.   $username = "root";   //replace your username
  4.   $password = "toor";        //replace your password
  5.   $dbname = "shop";    //replace your database name
  6.  
  7.   // Create connection
  8.    $conn = mysqli_connect($servername, $username, $password, $dbname);
  9.  
  10.  
  11.     if ( isset($_GET["user"]) and isset($_GET["password"]) )
  12.     {
  13.         $username = $_GET["user"];
  14.         $password = md5( $_GET["password"] );
  15.  
  16.         $val = "SELECT * FROM users WHERE name = '$username' and password = '$password'";
  17.     $test = mysqli_query( $conn, $val );
  18.  
  19.         if ( !$res = mysqli_query( $conn, $val ) )
  20.         {
  21.             echo "Error: Our query failed to execute and here is why: <br/>";
  22.             echo "Query: " . $val . "<br/>";
  23.             echo "Errno: " . $conn->errno . "<br/>";
  24.             echo "Error: " . $conn->error . "<br/>";
  25.         }
  26.         else
  27.         {
  28.             $data = $res->fetch_all();
  29.             echo "Your card number: " . $data[0][2];
  30.         }
  31.     }
  32. ?>
  33.  
  34. <!DOCTYPE html>
  35. <html lang="en">
  36.     <head>
  37.         <title>Shop login</title>
  38.     </head>
  39.     <body>
  40.         <form action="" method="GET" class="form-signin">
  41.             <h2>Please login</h2>
  42.             <label for="user" class="sr-only">Username</label>
  43.             <input type="text" name="user" id="user" class="form-control" placeholder="Username" required="" autofocus=""><br/><br/>
  44.             <label for="password" class="sr-only">Password</label>
  45.             <input type="password" id="password" name="password" class="form-control" placeholder="Password" required=""><br/><br/>
  46.             <button class="btn btn-lg btn-primary btn-block" type="submit">Log in</button>
  47.         </form>
  48.     </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement