Share Pastebin
Guest
Public paste!

Login.php

By: a guest | Mar 21st, 2010 | Syntax: HTML | Size: 1.22 KB | Hits: 120 | Expires: Never
Copy text to clipboard
  1.    <html>
  2.    <head>
  3.    </head>
  4. <body background="http://www.wallpaperweb.org/wallpaper/Games/1920x1200/deathwing_1920x1200.jpg"/>
  5.  
  6.  
  7.     <?php
  8. session_start();
  9.  
  10. include "dbConfig.php";
  11.  
  12. if ($_GET["op"] == "<strong class="highlight">login</strong>")
  13.  {
  14.  if (!$_POST["username"] || !$_POST["password"])
  15.   {
  16.   die("You need to provide <strong class="highlight">a</strong> username and password.");
  17.   }
  18.  
  19.  
  20.  $q = "SELECT * FROM `dbUsers` "
  21.   ."WHERE `username`='".$_POST["username"]."' "
  22.   ."AND `password`=PASSWORD('".$_POST["password"]."') "
  23.   ."LIMIT 1";
  24.  
  25.  $r = mysql_query($q);
  26.  
  27.  if ( $obj = @mysql_fetch_object($r) )
  28.   {
  29.  
  30.   $_SESSION["valid_id"] = $obj->id;
  31.   $_SESSION["valid_user"] = $_POST["username"];
  32.   $_SESSION["valid_time"] = time();
  33.  
  34.  
  35.   Header("Location: members.php");
  36.   }
  37.  else
  38.   {
  39.  
  40.   die("Sorry, could not log you in. Wrong <strong class="highlight">login</strong> information.");
  41.   }
  42.  }
  43. else
  44.  {
  45.  
  46.  echo "<form action=\"?op=login\" method=\"POST\">";
  47.  echo "Username: <input name=\"username\" size=\"15\"><br />";
  48.  echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />";
  49.  echo "<input type=\"submit\" value=\"Login\">";
  50.  echo "</form>";
  51.  }
  52. ?>
  53.              </body>
  54. </html>