Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. // dBase file
  5. include "dbConfig.php";
  6.  
  7. if ($_GET["op"] == "login")
  8.  {
  9.  if (!$_POST["username"] || !$_POST["password"])
  10.   {
  11.   die("You need to provide a username and password.");
  12.   }
  13.  
  14.  // Create query
  15.  $q = "SELECT * FROM `dbUsers.` "
  16.   ."WHERE `username`='".$_POST["username"]."' "
  17.   ."AND `password`=PASSWORD('".$_POST["password"]."') "
  18.   ."LIMIT 1";
  19.  // Run query
  20.  $r = mysql_query($q);
  21.  
  22.  if ( $obj = @mysql_fetch_object($r) )
  23.   {
  24.   // Login good, create session variables
  25.   $_SESSION["valid_id"] = $obj->id;
  26.   $_SESSION["valid_user"] = $_POST["username"];
  27.   $_SESSION["valid_time"] = time();
  28.  
  29.  // Redirect to member page
  30.   header("Location: /members.php");
  31.   }
  32.  else
  33.   {
  34.   // Login not successful
  35.   die("Sorry,  we could not log you in to LoveBubble. There seems to be a problem with your login information.");
  36.   }
  37.  }
  38. else
  39.  {
  40.  
  41. //If all went right the Web form appears and users can log in
  42.  
  43. echo "<html>";
  44. echo "<LINK REL=StyleSheet HREF='style.css' TYPE='text/css' MEDIA=screen>";
  45. echo "<head>";
  46. echo "<title>LoveBubble</title>";
  47. echo "</head>";
  48. echo "<body>";
  49. echo "<div class='top'>";
  50. echo "</br>";
  51. echo "<center><img src='images/bubblelogo.jpg' alt='LoveBubble'/></center>";
  52. echo "</br>";
  53. echo "</br>";
  54. echo "</br>";
  55. echo "</div>";
  56. echo "<div class='main'>";
  57. echo "<center>";
  58. echo "<img src='images/bubbles.jpg'/>";
  59. echo "</center>";
  60. echo "<center>";
  61.  echo "<form action=\"?op=login\" method=\"POST\">";
  62.  echo "Username: <input name=\"username\" size=\"15\"><br />";
  63.  echo "Password: <input type=\"password\" name=\"password\" size=\"15\"><br />";
  64.  echo "<input type=\"submit\" value=\"Login\">";
  65. echo "<form>";
  66. echo "<Input Type='button' Value='Register' Onclick=window.location.href='/register.php'>";
  67. echo "</form>";
  68. echo "</center>";
  69. echo "</body>";
  70. echo "</html>";
  71.  }
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement