Guest User

Untitled

a guest
Mar 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.32 KB | None | 0 0
  1. <?php session_start();?>
  2. <!doctype html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta name="description" content="">
  6.     <meta name="keywords" content="" />
  7.     <meta name="author" content="Matthew Day">
  8.     <title>Neptune Direct :: Members</title>
  9.     <link rel="stylesheet" href="style/default.css">
  10. </head>
  11. <body>
  12.     <div id='container'>
  13.         <div id='header'>
  14.             <img src='img/logo.png' /><br />
  15.         </div>
  16.         <div id="navigation">
  17.            <?php include('application/nav.php'); ?>
  18.         </div>
  19.         <div id="content-container">
  20.             <div id="content">
  21.                 <?php
  22.                 $username = $_POST['username'];
  23.                 $password = sha1($_POST['password']);
  24.                 $conn = mysql_connect("localhost", "xmattydx_admin", "m4ttyd!");
  25.  
  26.                 if (!$conn) {
  27.                     echo "Unable to connect to DB: " . mysql_error();
  28.                     exit;
  29.                 }
  30.  
  31.                 if (!mysql_select_db("xmattydx_neptune")) {
  32.                     echo "Unable to select xmattydx_neptune: " . mysql_error();
  33.                     exit;
  34.                 }
  35.  
  36.                 $sql = "SELECT * FROM members WHERE username = '" . $username . "' AND password = '" . $password . "'";
  37.  
  38.                 $result = mysql_query($sql);
  39.  
  40.                 if (!$result) {
  41.                     echo "Could not successfully run query ($sql) from DB: " . mysql_error();
  42.                     exit;
  43.                 }
  44.  
  45.                 if (mysql_num_rows($result) == 0) {
  46.                     echo "No rows found, nothing to print so am exiting";
  47.                 }
  48.  
  49.                 while ($row = mysql_fetch_assoc($result)) {
  50.                     if ($row['username'] == $username || $row['password'] == $password) {
  51.  
  52.                         $user_id = $row['customer_id'];
  53.                         $un = $row['username'];
  54.  
  55.                         $_SESSION['member_id'] = $user_id;
  56.                         $_SESSION['username'] = $un;
  57.                         header('Location:index.php');
  58.                         exit;
  59.                     } else {
  60.                         echo "Username or Password was in correct, please try again in 1 minute.";
  61.                     }
  62.                 }
  63.                 ?>
  64.             </div>
  65.         </div>
  66.     </div>
  67. </body>
  68. </html>
Add Comment
Please, Sign In to add comment