Select
To select all users include User and Database classes and use methods (e.g. getAll) inside User. We also use method foreach(<?php foreach ($users as $user):?>) to call all users from the database and display them onto the screen. Because we used session to login, we have to put session start at the header to avoid users who do not login to access the page.
<?php
include_once 'Database.php';
include_once 'User.php';
$insertModel = new User();
if ($_POST) {
$insertModel->Create($_POST['gender'], $_POST['lName'], $_POST['fName'], $_POST['email'], password_hash($_POST['password'], PASSWORD_DEFAULT));
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>insert</title>
</head>
<body>
<main>
<form action="" method="post">
<p>
<label>Gender</label>
<select name="gender" required>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</p>
<p>
<label for="name">First Name</label>
<input name="fName" type="text" placeholder="Enter first name">
</p>
<p>
<label for="lName">First Name</label>
<input name="lName" type="text" placeholder="Enter last name">
</p>
<p>
<label for="email">Email</label>
<input name="email" type="text" placeholder="Enter email">
</p>
<p>
<label for="password">Password</label>
<input name="password" type="password" placeholder="Enter password">
</p>
<button type="submit">Submit</button>
</form>
</main>
</body>
</html>
File: select.php