0

I created a login page for my project website. I'm completely new in using PHP so I've looked at a fair few examples on how to create a login file but all of the ones I've attempted so far have only lead me to a blank white screen with no errors and no content in the page source.

Any help would be appreciated.

This is my login.php file -

   <?php
ini_set('display_errors','1');

include "connect.php"

if(isset($_POST['submit'])){
$Uname = filter_input(INPUT_POST, 'Uname', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'Pword', FILTER_SANITIZE_STRING);
$hashedpassword = password_hash($password, PASSWORD_DEFAULT);
$check = mysqli_prepare($conn, "SELECT * FROM Userdatabase WHERE Username = ? AND Password = ?");
mysqli_stmt_bind_param($check, "ss", $Uname, $hashedpassword);
mysqli_stmt_bind_result($check, $result);
if ($Uname == "NTLADMIN" AND password_verify($password, $hashedpassword))
{
header("Location: admin.html");
}
if (mysqli_num_rows($result) == 1)
{
$_SESSION['Username'] = $Uname;
$nameget = mysqli_prepare($conn, "SELECT name FROM userdatabase WHERE Username = ? AND Password = ?");
mysqli_stmt_bind_param($nameget, "ss", $Uname, $password);
mysqli_stmt_bind_result($name);
setcookie("user", $name);
header("Location: index.html");
}
mysqli_stmt_close($inputs);
mysqli_close();
}
?>

<!DOCTYPE html>
<html>
<head>
  <title> Login </title>
  <meta charset = "UTF-8">
  <meta name="viewport" content="width=device-width, initial_scale=1.0">
  <link rel = "stylesheet" href = "css/bootstrap.css">
  <link rel = "stylesheet" href = "css/style.css">
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
</head>
<body>
</br>
</br>
  <div class="container" style = "background-color: rgba(170, 170, 170, 0.88);">
        <form class="form-signin" action = "login.php" method="post">
          <h1 class="form-signin-heading">LOGIN</h1>
        </br>
          <label for="Uname" class="sr-only">Username</label>
          <input name="Uname" type="text" id="Uname" class="form-control" placeholder="Username" required autofocus>
          <label for="Pword" class="sr-only">Password</label>
          <input name ="Pword" type="password" id="Pword" class="form-control" placeholder="Password" required>
          <button class="btn btn-lg btn-primary btn-block" for="submit" type= "submit">Submit</button>
        </form>
</br>
      </div>

</body>
</html>

1 Answers1

0

add a NAME to your button

<button class="btn btn-lg btn-primary btn-block" for="submit" type= "submit" name="submit">Submit</button>
  • Thanks, although the page is still showing up as a blank screen for some reason. It must be something to do with the php code because when I moved it to a seperate file as the form action, it didn't show the blank screen until after the submit button was pressed. – ErTaren Dec 04 '18 at 02:09