<!DOCTYPE html>
<?php
// Check if the user is already logged in, if yes then redirect him/her to dashboard page
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
print('<div class="page-header">');
print('<h1>Hi, <b>');
echo htmlspecialchars($_SESSION["username"]);
print('</b> Welcome to our site.</h1></div>');
exit;
}
// Define variables and initialize with empty values
$username = $password = $confirm_password = "";
$username_err = $password_err = $confirm_password_err = "";
?>
<html lang="en">
<head>
<title>Opus Reports Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
body{ font: 12px verdana; text-align: center; }
</style>
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/Linearicons-Free-v1.0.0/icon-font.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<?Php
$mycolour = '';
if (!empty( $_COOKIE['favcolour'])) {
$mycolour = $_COOKIE['favcolour'];
}
?>
<body style="background-color: <?Php echo $mycolour;?>;">
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form class="login100-form validate-form">
<span class="login100-form-title p-b-43" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
Login to Reports
</span>
<div class="wrap-input100 validate-input" data-validate = "A Current Valid UserID is required for access:e.g. 1234">
<input class="input100" type="text" name="userid" id="userid" value="Admin" autocomplete="on">
<span class="focus-input100"></span>
<span class="label-input100">UserId</span>
</div>
<div class="wrap-input100 validate-input" data-validate="A Password is required">
<input class="input100" type="password" name="password" id="password" maxlength="8" autocomplete="on">
<span class="focus-input100"></span>
<span class="label-input100">Password</span>
</div>
<div class="flex-sb-m w-full p-t-3 p-b-32">
<div class="contact100-form-checkbox">
<input class="input-checkbox100" id="ckb1" type="checkbox" name="remember-me">
<label class="label-checkbox100" for="ckb1">
Remember me
</label>
</div>
<div>
<a href="#" class="txt1">
Forgot Password?
</a>
</div>
</div>
<div class="container-login100-form-btn">
<button type="submit" class="login100-form-btn">
Login
</button>
</div>
<div class="text-center p-t-46 p-b-20">
<span class="txt2">
or sign up using
</span>
</div>
<div class="login100-form-social flex-c-m">
<a href="#" class="login100-form-social-item flex-c-m bg1 m-r-5">
<i class="fa fa-facebook-f" aria-hidden="true"></i>
</a>
<a href="#" class="login100-form-social-item flex-c-m bg2 m-r-5">
<i class="fa fa-twitter" aria-hidden="true"></i>
</a>
</div>
</form>
<div class="login100-more" style="background-image: url('images/bg-01.png');">
</div>
</div>
</div>
</div>
<?Php
$dsn = 'odbc:MY_DSN';
$user = '8888';
$pass = '****';
//$pdo = new PDO($dsn, $user, $pass);
//sasql_connect("uid=dba;pwd=sql");
try {
$pdo = new PDO($dsn, $user, $pass);
$pdo_status = "Sybase Connected Okay" . "\n";
//echo $pdo_status;
} catch(PDOException $e) {
error_log($e->getMessage());
echo 'Connection failed! No connection no queries!: ' . $e->getMessage();
}
/* Enable error reporting for all types except for deprecated and strict. */
error_reporting(E_ALL);
//if($_SERVER["REQUEST_METHOD"] == "POST"){
// Check if username is empty
if(empty(trim($_POST["userid"]))){
$username_err = "Please enter a correct userid.";
} else{
$username = trim($_POST["userid"]);
}
// Check if password is empty
if(empty(trim($_POST["password"]))){
$password_err = "Please enter your password.";
} else{
$password = trim($_POST["password"]);
}
/* print('<span class="help-block">');
echo $password_err;
print('</span>'); */
// Validate credentials
if(empty($username_err) && empty($password_err)){ // No Errors do select
// Prepare a select statement
Console.log($username);
print_r ($username);
$sql = 'Select userid,username,userpassword from users where userid = :username';
if($stmt = $pdo->prepare($sql)){
// Bind variables to the prepared statement as parameters
//$stmt->bindParam('s', $param_username, PDO::PARAM_STR);
// Set parameters
$param_username = trim($_POST["userid"]);
// Attempt to execute the prepared statement
//$stmt->execute(['transactionNo' => $number, 'tillid' => $till]);
if($stmt->execute(['userid' => $username])){
// Check if username exists, if yes then verify password
//echo ($userid);
$result=$stmt->fetch(pdo::FETCH_ASSOC);
If(!$result){
echo "failed Login";
}
if($stmt-> rowCount() == 1){
if($row = $stmt->fetch()){
$id = $row["userid"];
$username = $row["username"];
$hashed_password = $row["password"];
if(password_verify($password, $hashed_password)){
// Password is correct, so start a new session
session_start();
// Store data in session variables
$_SESSION["loggedin"] = true;
$_SESSION["id"] = $id;
$_SESSION["username"] = $username;
$_SESSION['loggedin_time'] = time();
// Redirect user to welcome page perhaps
header('location: dashboard.php');
} else{
// Display an error message if password is not valid
$password_err = "The password you entered was not valid.";
}
}
} else{
// Display an error message if username doesn't exist
$username_err = "No account found with that username.";
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
unset($stmt);
}
}
// Close connection
unset($pdo);
file_put_contents( 'C:\temp\logs\debug' . time() . '.log', var_export( $username, true), FILE_APPEND);
//}
?>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/daterangepicker/moment.min.js"></script>
<script src="vendor/daterangepicker/daterangepicker.js"></script>
<!--===============================================================================================-->
<script src="vendor/countdowntime/countdowntime.js"></script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html>