Guest User

Untitled

a guest
Dec 18th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  
  5. *   File:           login.php
  6. *   By:         Carson Page
  7. *   Date:       10/7/12
  8. *
  9. *   This script allows for the secure login into my website.
  10. *
  11. *
  12. *=====================================
  13. */
  14.  
  15. {       //  Secure Connection Script
  16.         include('../../../WebSecure/dbConfig.php');
  17.         $dbSuccess = false;
  18.         $dbConnected = mysql_connect($db['hostname'],$db['username'],$db['password']);
  19.        
  20.         if ($dbConnected) {    
  21.             $dbSelected = mysql_select_db($db['database'],$dbConnected);
  22.             if ($dbSelected) {
  23.                 $dbSuccess = true;
  24.             }  
  25.         }
  26.         //  END Secure Connection Script
  27. }
  28.  
  29. if ($dbSuccess) {
  30.    
  31.     $username = $_POST['Username'];
  32.     $password = $_POST['Password'];
  33.    
  34.     if(isset($username) and isset($password)){
  35.         $charecters = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQURSTUVWXYZ';
  36.         $sessionID = "";
  37.         for ($i =0; $i < 64; $i++){
  38.             $sessionID .= $charecters[rand(0,strlen($charecters) - 1)];
  39.         }
  40.         $_SESSION['SID'] = $sessionID;
  41.         $password = hash('sha256', $password);
  42.         if(mysql_query("UPDATE loginInfo SET sid WHERE username='".$username."' AND password='".$password.")){
  43.             echo('Login Sucessful!');  
  44.         }
  45.         else {
  46.             echo('Login Falied');
  47.         }
  48.         unset($password);
  49.         unset($sessionID);     
  50.     }
  51.     else{
  52.         header('Location: 192.168.1.3/TMS/index.php');
  53.     }
  54.    
  55. }
  56. ?>
Add Comment
Please, Sign In to add comment