I have created a database in phpmyadmin. I am trying to create a register and login, but I am creating a config.php file first which you can see below. I have used placeholders instead of my username and password. However once the web page is loaded it is just saying could not connect.
<?php
$conn = mysqli_connect("localhost", "username", "password");
if($conn){
die("could not connect" . mysqli_error($conn));
}
mysqli_close($conn);
?>
I am not sure if I am connected to my database, as I am new to php. I have created a register form, but anytime I type register.php onto the end of the url it just displays the could not connect. It does not show any of my form and there are no errors in the console. Below is the php I have so far for the register.php. I am just trying to test it at the minute, but the html part isn't showing at all so I cannot input a name to see if it is working.
<?php
require_once('config.php');
$username = $_POST ['username'];
?>
PHP is before the head tag in html for the register.php. Does anyone have any suggestions as to why my register form is not appearing?
register.php
<?php
require_once('config.php');
$username = $_POST ['username'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Trip Guider</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
<!-- Plugin CSS -->
<link href="vendor/magnific-popup/magnific-popup.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/creative.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body id="page-top" >
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<div class="dropdown" id="myDropdown">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Menu
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">Home</a></li>
<li><a href="gallery.html">View Holiday Gallery</a></li>
<li><a href="itinerary.html">View Itinerary</a></li>
<li><a href="settings.html">Settings</a></li>
</ul>
</div>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="card card-container">
<a href="index.html">
<img id="profile-img" class="profile-img-card" src="//ssl.gstatic.com/accounts/ui/avatar_2x.png" alt="logo" />
</a>
<p id="profile-name" class="profile-name-card"></p>
<form class="form-signin" action="" method="post">
<input type="text" id="inputEmail" class="form-control" placeholder="Username" required autofocus>
<span id="reauth-email" class="reauth-email"></span>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">Register</button>
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">Sign in</button>
</form><!-- /form -->
</div><!-- /card-container -->
</div><!-- /container -->
<script src="js/creative.min.js"></script>
<script src="js/jquery.js"></script>
</body>
</html>