Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.70 KB | None | 0 0
  1. <body>
  2. <table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  3.   <tr>
  4.     <td width="413"><img src="images/ugmed_01.png" width="413" height="250" alt="logo" /></td>
  5.     <td width="540" background="images/ugmed_02.png">&nbsp;</td>
  6.     <td width="27" background="images/ugmed_04.png">&nbsp;</td>
  7.   </tr>
  8. </table>
  9. <table width="980px" height="500px" border="0" align="center" cellpadding="0" cellspacing="0">
  10.   <tr>
  11.     <td><table width="100%" height="100%" border="0" cellspacing="2" cellpadding="2">
  12.       <tr>
  13.         <td>&nbsp;</td>
  14.         <td>&nbsp;</td>
  15.         <td>&nbsp;</td>
  16.       </tr>
  17.       <tr>
  18.         <td>&nbsp;</td>
  19.         <td>&nbsp;</td>
  20.         <td>&nbsp;</td>
  21.       </tr>
  22.       <tr>
  23.         <td>&nbsp;</td>
  24.         <td>
  25.        
  26.    <?php
  27.  // Connects to your Database
  28.  mysql_connect("localhost", "root", "owwned") or die(mysql_error());
  29.  mysql_select_db("vezba") or die(mysql_error());
  30.  //Checks if there is a login cookie
  31.  if(isset($_COOKIE['ID_my_site']))
  32.  //if there is, it logs you in and directes you to the members page
  33.  {  $username = $_COOKIE['ID_my_site'];
  34.     $pass = $_COOKIE['Key_my_site'];
  35.         $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
  36.     while($info = mysql_fetch_array( $check ))  
  37.         {
  38.         if ($pass != $info['password'])
  39.             {
  40.                         }
  41.         else
  42.             {
  43.             header("Location: members.php");
  44.  
  45.             }
  46.         }
  47.  }
  48.  //if the login form is submitted
  49.  if (isset($_POST['submit'])) { // if form has been submitted
  50.  
  51.  // makes sure they filled it in
  52.     if(!$_POST['username'] | !$_POST['pass']) {
  53.         die('You did not fill in a required field.');
  54.     }
  55.     // checks it against the database
  56.  
  57.     if (!get_magic_quotes_gpc()) {
  58.         $_POST['email'] = addslashes($_POST['email']);
  59.     }
  60.     $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());
  61.  
  62.  //Gives error if user dosen't exist
  63.  $check2 = mysql_num_rows($check);
  64.  if ($check2 == 0) {
  65.         die('That user does not exist in our database. <a href=add.php>Click Here to Register</a>');
  66.                 }
  67.  while($info = mysql_fetch_array( $check ))    
  68.  {
  69.  $_POST['pass'] = stripslashes($_POST['pass']);
  70.     $info['password'] = stripslashes($info['password']);
  71.     $_POST['pass'] = md5($_POST['pass']);
  72.  
  73.  //gives error if the password is wrong
  74.     if ($_POST['pass'] != $info['password']) {
  75.         die('Incorrect password, please try again.');
  76.     }
  77.    
  78.      else
  79.  {
  80.  // if login is ok then we add a cookie
  81.      $_POST['username'] = stripslashes($_POST['username']);
  82.      $hour = time() + 3600;
  83.  setcookie(ID_my_site, $_POST['username'], $hour);
  84.  setcookie(Key_my_site, $_POST['pass'], $hour);  
  85.  
  86.  //then redirect them to the members area
  87.  header("Location: members.php");
  88.  }
  89.  }
  90.  }
  91.  else
  92.  {   
  93.  
  94.  // if they are not logged in
  95.  ?>
  96.  <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
  97.  <table border="0">
  98.  <tr><td colspan=2><h1>Login</h1></td></tr>
  99.  <tr><td>Username:</td><td>
  100.  <input type="text" name="username" maxlength="40">
  101.  </td></tr>
  102.  <tr><td>Password:</td><td>
  103.  <input type="password" name="pass" maxlength="50">
  104.  </td></tr>
  105.  <tr><td colspan="2" align="right">
  106.  <input type="submit" name="submit" value="Login">
  107.  </td></tr>
  108.  </table>
  109.  </form>
  110.  <?php
  111.  }
  112.  
  113.  ?>
  114.        
  115.         </td>
  116.         <td>&nbsp;</td>
  117.       </tr>
  118.     </table></td>
  119.   </tr>
  120. </table>
  121. <table width="980" height="81"border="0" align="center" cellpadding="0" cellspacing="0">
  122.   <tr>
  123.     <td width="11" background="images/ugmed_07.png">&nbsp;</td>
  124.     <td width="954" background="images/ugmed_08.png">&nbsp;</td>
  125.     <td width="15" background="images/ugmed_11.png">&nbsp;</td>
  126.   </tr>
  127. </table>
  128. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement