<?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 = "INSERT INTO loginform (username, password) VALUES ('$uname', '$password')"; $result = pg_query($sql); $_SESSION['uname'] = $uname; echo "<script>location.href='questions.php'</script>"; } ?> <html> <head> <title>Login Page</title> <link rel="dns-prefetch" href="//fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet"> <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> <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="login.php">Login </a> </li> </ul> </div> </div> </nav> </div> <div class="container"> <div class="d-flex justify-content-center h-100"> <div class="card"> <div class="card-header"> <h3>Register</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"> <input type="submit" value="Register" class="btn float-right login_btn"> </div> </form> </div> </div> </div> </div> </body>