Jump to content

AmbientGuitar

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by AmbientGuitar

  1. I have tried several things to get this working. I am getting a black screen with a white dot. Not sure what I'm doing wrong. Apparently it should be a red dot. I want to get this working first as I have BASE64 to display from a table in the database.By teh way I am fairly new to PHP so please go easy! <?php // Define the Base64 value you need to save as an image header ('Content-Type: image/png'); $b64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // Obtain the original content (usually binary data) $bin = base64_decode($b64); // Load GD resource from binary data $im = imageCreateFromString($bin); //echo $im; // Make sure that the GD library was able to load the image // This is important, because you should not miss corrupted or unsupported images if (!$im) { die('Base64 value is not a valid image'); } // Specify the location where you want to save the image //; echo '<img src="data:image;base64, ' .$im. ' " style="width:5in;height:5in;">'; //echo '<img src="data:image/jpeg;base64,data:image/jpeg;base64,$b64>")'; //echo '<img src= ' .$bin. '/>'; //print("<img src= $im 'height: 200px; width: 350px;'>"); //$img_file = '/img/filename.png'; // Save the GD resource as PNG in the best possible quality (no compression) // This will strip any metadata or invalid contents (including, the PHP backdoor) // To block any possible exploits, consider increasing the compression level //imagepng($im, $img_file, 0); ?>
  2. Thanks guys! Making progress. I think its a PDO param that's causing this. However, jodunno was correct. My HTML i snot as it used to be. Thanks. I will get back when i have a solution. I have made progress.
  3. Sorry, I have uncommented and it has removed the errors. The console is showing nothing but redirection isn't working. How do you debug php. I am only doing this s few weeks!
  4. Sorry. Notice: Undefined index: userid in C:\inetpub\wwwroot\Reports\login.php on line 162 Notice: Undefined index: password in C:\inetpub\wwwroot\Reports\login.php on line 171 When I add userid and password it checks users table if valid then should redirect to dashboard.php
  5. <!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>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.