Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.08 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  
  5. This script was downloaded at:
  6.  
  7. LightPHPScripts.com
  8.  
  9. Please support us by visiting
  10.  
  11. out website and letting people
  12.  
  13. know of it.
  14.  
  15. Produced under: LGPL
  16.  
  17. */
  18.  
  19.  
  20.  
  21. /* Start session */
  22.  
  23. if($startSession == TRUE){ session_start();}
  24.  
  25.  
  26.  
  27. /* Config file */
  28.  
  29. include('config.php');
  30.  
  31.  
  32.  
  33. /* Check for submition */
  34.  
  35. if($_POST['submitID'] == 1){
  36.  
  37.    
  38.  
  39.     /* Connect to database */
  40.  
  41.     if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}
  42.  
  43.        
  44.  
  45.     /* sanitize and check info */
  46.  
  47.     $userName = mysql_real_escape_string($_POST['userName'],$dbc);
  48.  
  49.     $password = mysql_real_escape_string($_POST['password'],$dbc);
  50.  
  51.    
  52.  
  53.     if($userName == NULL) { $message = 'Please enter username.';}
  54.  
  55.     if($message == NULL && $password == NULL){ $message = 'Please enter password.';}
  56.  
  57.    
  58.  
  59.     if($message == NULL)
  60.  
  61.     {              
  62.  
  63.         $userQuery = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM " . $tableName .
  64.  
  65.         " WHERE `" . $userNameField . "`='$userName' AND `" . $userPasswordField . "`='$password'"));      
  66.  
  67.        
  68.  
  69.         /* If usercount is more than 0 -> ok */
  70.  
  71.         if($userQuery[0] > 0){
  72.  
  73.             /* Disconnect from database */
  74.  
  75.             if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
  76.  
  77.    
  78.  
  79.             $_SESSION['isLoged'] = 'yes';
  80.  
  81.             $_SESSION['userName'] = $userName;
  82.  
  83.            
  84.  
  85.             /* add cookies ?*/
  86.  
  87.             /* expire in 1 hour */
  88.  
  89.             if($useCookies == TRUE)
  90.  
  91.             {
  92.  
  93.                 setcookie("isLoged", 'yes', time()+logedInFor, "/", ".$domainName", 1);
  94.  
  95.                 setcookie("userName", $userName, time()+logedInFor, "/", ".$domainName", 1);
  96.  
  97.             }
  98.  
  99.  
  100.  
  101.             /* Redirect to login page */
  102.  
  103.             header("Location: $loginPage");
  104.  
  105.             exit();
  106.  
  107.         } else {
  108.  
  109.             $message = 'Invalid username and/or password!';
  110.  
  111.         }
  112.  
  113.     }
  114.  
  115.     /* Disconnect from database */
  116.  
  117.     if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
  118.  
  119. }
  120.  
  121. ?>
  122.  
  123. <!--
  124.  
  125. /*
  126.  
  127. This script was downloaded at:
  128.  
  129. LightPHPScripts.com
  130.  
  131. Please support us by visiting
  132.  
  133. out website and letting people
  134.  
  135. know of it.
  136.  
  137. Produced under: LGPL
  138.  
  139. */
  140.  
  141. -->
  142.  
  143. <?php
  144.  
  145.  
  146.  
  147. /* Display error messages */
  148.  
  149. if($message != NULL){?>
  150.  
  151. <table width="100%"  border="0" cellpadding="3" cellspacing="0" bgcolor="#FFCCCC">
  152.  
  153.   <tr>
  154.  
  155.     <td><div align="center"><strong><font color="#FF0000"><?=$message;?></font></strong></div></td>
  156.  
  157.   </tr>
  158.  
  159. </table>
  160.  
  161. <?php } ?>
  162.  
  163. <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="login" id="login" style="display:inline;">
  164.  
  165.   <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  166.  
  167.  
  168.  
  169.     <tr>
  170.  
  171.       <td width="47%"><strong><font color='#F4ED1A'>Username:</strong>
  172.  
  173.       <width="53%"><input name="userName" type="text" id="userName">
  174.  
  175.    
  176.  
  177.       <strong><font color='#F4ED1A'>Password:</strong>
  178.  
  179.       <input name="password" type="password" id="password">
  180.  
  181.      <colspan="2"><font face="Georgia, Times New Roman, Times, serif"><strong>
  182.  
  183.           <input name="Submit" type="submit" id="Submit" value="Log In">
  184.  
  185.           <input name="submitID" type="hidden" id="submitID" value="1">
  186.  
  187. </strong></font> </div></td>
  188.  
  189.     </tr>
  190.  
  191.  
  192.   </table>
  193.  
  194. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement