Advertisement
droidus

Untitled

Jun 9th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.82 KB | None | 0 0
  1. <?php
  2. if (!isset($_SESSION))
  3.     {
  4.         session_start();
  5.     }
  6. ?>
  7. <?php require_once('../Connections/uploader.php'); ?>
  8. <?
  9. function loginFormErrorsCheck ($loginUsername, $loginPassword) {
  10.   if (empty($loginUsername) || empty($loginPassword)) {
  11.     return true;
  12.   } else {
  13.     return false;
  14.   }
  15. }
  16. ?>
  17. <?php
  18. if (isset($_POST['login'])) {
  19.    
  20.     $loginUsername = $_POST['uname'];  
  21.     $loginPassword = $_POST['pword'];
  22.    
  23.     $errors = loginFormErrorsCheck ($loginUsername, $loginPassword);    
  24.    
  25.     if (!$errors) {
  26.        
  27.         mysql_select_db($database_uploader, $uploader);    
  28.         $query = "SELECT * FROM members WHERE uname='"
  29.         . mysql_real_escape_string($loginUsername) . "' AND pword='"
  30.         . mysql_real_escape_string($loginPassword) . "'";  
  31.         $result = mysql_query($query) or die(mysql_error());
  32.        
  33.         // make sure the username and password were found
  34.         if (mysql_num_rows($result) > 0) {
  35.             $row = mysql_fetch_array($result) or die(mysql_error());
  36.            
  37.             if ($loginUsername == "admin") { // Admin Login
  38.                 mysql_close($result);
  39.                 $_SESSION['admin'] = "Admin.";
  40.                 header('Location: admin.php');
  41.                 exit;
  42.             }
  43.            
  44.             if ($row['acntStatus'] == 0) {  // If account is OK
  45.                 mysql_close($result);
  46.             }
  47.             else // If account is in bad standing
  48.                 {
  49.                     $errors[0]="Your account has been temporarily/permanently disabled, or terminated. Please contact us for more details.";
  50.                 }
  51.            
  52.             if ($row['activated'] == 1) {
  53.                
  54.             }
  55.             else {$errors[1] = "Your account is not yet activated.";}
  56.            
  57.             if ($row['activated'] == 1 && $row['acntStatus'] == 0)
  58.             {
  59.                 mysql_close($result);
  60.                 $_SESSION[$user] = $loginUsername;
  61.                 header('Location: users/' . $row['uname'] . '/index.php');
  62.                 exit;
  63.             }
  64.         }
  65.     }
  66. }
  67. ?>
  68.  
  69. <?php
  70. if (isset($errors) && !empty($errors)) {
  71.     for ($i=0; $i<2; $i++) {
  72.         echo "<p class='errors'>$errors[$i]<br></p>";
  73.     }
  74. }
  75. ?>
  76. <style>
  77. .errors {
  78.     color:#F00;
  79.     font-weight:bold;
  80. }
  81. </style>
  82. <form action="" method="post" id="login" name="login" >
  83. <table border="1" align="center">
  84.   <tr>
  85.     <td colspan="2"><h3>Login</h3>
  86.       <p>Please enter a username to continue being uploading your files:</p></td>
  87.     </tr>
  88.   <tr>
  89.     <td>Username: </td>
  90.     <td><input type="text" name="uname" id="uname" value="<? if (isset($errors)) {echo $_POST['uname'];} ?>" /></td>
  91.   </tr>
  92.   <tr>
  93.     <td>Password: </td>
  94.     <td><input name='pword' type='password' value="<? if (isset($errors)) {echo $_POST['pword'];} ?>" /></td>
  95.   </tr>
  96.   <tr>
  97.     <td colspan="2">By clicking &quot;Submit&quot;, you have read agreed to the <a href="#">Terms and Conditions</a>. </td>
  98.   </tr>
  99.     <tr>
  100.       <td>&nbsp;</td>
  101.       <td><input type="submit" name="login" id="login" value="Submit" /></td>
  102.     </tr>
  103. </table>
  104. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement