Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!isset($_REQUEST['username']))
- {
- include 'form.html.php';
- }
- else
- {
- $username = $_REQUEST['username'];
- $password = $_REQUEST['password'];
- $link = mysqli_connect('localhost', 'root', 'youaintgettinmypasswordson');
- if (!$link)
- {
- $output = "Unable to connect to the database server.";
- include "output.html.php";
- exit();
- }
- if (!mysqli_set_charset($link, 'utf8'))
- {
- $output = "Unable to set database connection encoding.";
- include "output.html.php";
- exit();
- }
- if (!mysqli_select_db($link, 'users'))
- {
- $output = "Unable to locate the users.";
- include "output.html.php";
- exit();
- }
- $sql = 'SELECT * FROM users_table WHERE username LIKE "' . $username . '" AND password LIKE MD5("' . $password . '");';
- if (!($result=mysqli_query($link, $sql)))
- {
- $output = "Error querying user database: " . mysqli_error($link);
- include "output.html.php";
- exit();
- }
- if (($row = mysqli_fetch_array($result))==NULL)
- {
- echo "User does not exist, or password incorrect!<br>";
- include 'form.html.php';
- }
- else
- {
- echo "Welcome " . $row['username'] . "!!";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment