Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * File: login.php
- * By: Carson Page
- * Date: 10/7/12
- *
- * This script allows for the secure login into my website.
- *
- *
- *=====================================
- */
- { // Secure Connection Script
- include('../../../WebSecure/dbConfig.php');
- $dbSuccess = false;
- $dbConnected = mysql_connect($db['hostname'],$db['username'],$db['password']);
- if ($dbConnected) {
- $dbSelected = mysql_select_db($db['database'],$dbConnected);
- if ($dbSelected) {
- $dbSuccess = true;
- }
- }
- // END Secure Connection Script
- }
- if ($dbSuccess) {
- $username = $_POST['Username'];
- $password = $_POST['Password'];
- if(isset($username) and isset($password)){
- $charecters = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQURSTUVWXYZ';
- $sessionID = "";
- for ($i =0; $i < 64; $i++){
- $sessionID .= $charecters[rand(0,strlen($charecters) - 1)];
- }
- $_SESSION['SID'] = $sessionID;
- $password = hash('sha256', $password);
- if(mysql_query("UPDATE loginInfo SET sid WHERE username='".$username."' AND password='".$password.")){
- echo('Login Sucessful!');
- }
- else {
- echo('Login Falied');
- }
- unset($password);
- unset($sessionID);
- }
- else{
- header('Location: 192.168.1.3/TMS/index.php');
- }
- }
- ?>
Add Comment
Please, Sign In to add comment