-
Thoeni Fabian (Student Com20) authoredThoeni Fabian (Student Com20) authored
login_20211223020646.php 3.90 KiB
<?php
session_start();
$host = "127.0.0.1";
$port = "5432";
$user = "postgres";
$password = "postgres";
$db = "demo";
$conn_string = "host=" . $host . " port=5432 dbname=" . $db . " user=" . $user . " password=" . $password . "";
pg_connect($conn_string);
if(isset($_POST['username'])){
$uname=$_POST['username'];
$password=$_POST['password'];
$sql="select * from loginform where username='".$uname."'AND password='".$password."'limit 1";
$result=pg_query($sql);
if(pg_num_rows($result)==1){
$_SESSION['uname']=$uname;
echo "<script>location.href='questions.php'</script>";
exit();
}
else{
echo"<script>alert('Wrong credentials, please try again!'</script>";
exit();
}
}
?>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" type="text/css" href="styles2.css">
<link rel="icon" type="image/png" href="img/favicon.png"/>
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand">
BattTho
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto">
</ul>
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="register.php">Register</a>
</li>
<li class="nav-item dropdown">
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
</div>
<div class="flex-container">
<div class="flex-welcome neon">
<h2>Hello and Welcome to our page!</h2>
<h3>Please Sign-in to see content</h3>
</div>
<div>
<div class="container">
<div class="d-flex justify-content-center h-100">
<div class="card">
<div class="card-header">
<h3>Sign In</h3>
</div>
<div class="card-body">
<form method="POST" actions="#">
<div class="input-group form-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" name="username" class="form-control" placeholder="username" required>
</div>
<div class="input-group form-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input type="password" name="password" class="form-control" placeholder="password" required>
</div>
<br>
<div class="form-group">
<div>
<input type="submit" value="Login" class="btn float-right login_btn">
</div>
<div>
<a href="register.php" class="btn float-right login_btn">Register</a>
</div>
</div>
</form>
</div>
<div class="card-footer">
<div class="d-flex justify-content-center links">
Don't have an account?<a href="register.php">Sign Up</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>