Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function customError($errno, $errstr)
- {
- echo "<b>Error:</b> [$errno] $errstr<br />";
- echo "The error has been logged.";
- error_log(date (DATE_RSS)." Error: [$errno]
- $errstr".chr(13).chr(10),3, "btecinvalidlogin.txt");
- }
- //set error handler
- set_error_handler("customError",E_USER_WARNING);
- session_start();
- $_SESSION['login'] = "";
- if($user!="" && $pass!="")
- {
- $conn = @mysql_connect ("79.170.44.92", "cl41-cclarke", "cRt9G/3KH") or die ("Sorry - unable to
- connect to MySQL database.");
- $rs = @mysql_select_db ("cl41-cclarke", $conn) or die ("error");
- $sql = "SELECT * FROM dbUser WHERE username = '$user' AND
- password = '$pass'";
- $rs = mysql_query($sql,$conn);
- $result = mysql_num_rows($rs);
- if ($result > 0) $validated = true;
- if($validated)
- {
- $_SESSION['login'] = "OK";
- $_SESSION['username'] = $user;
- $_SESSION['password'] = $pass;
- $ip = $_SERVER["REMOTE_ADDR"];
- $date = date("d-m-Y H:i:s");
- $file = 'bteclogin.txt';
- // Open the file to get existing content
- $current = file_get_contents($file);
- // Append a new person to the file
- $current .= "$user logged in from IP Address of $ip on $date"."\r\n";
- // Write the contents back to the file
- file_put_contents($file, $current);
- header('Location: protected02.php');
- }
- else
- {
- $_SESSION['login'] = "";
- trigger_error("Invalid username or password\n", E_USER_WARNING);
- }
- }
- else $_SESSION['login'] = "";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement