You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.7 KiB
PHP

<?php
require_once('scripts/userLogged.php');
userLogged();
?>
<?php
$meta = [
'title' => 'Register',
'description' => 'Register for an account',
'keywords' => ''
];
require_once('partial/head.php');
?>
<?php
require_once('partial/header.php');
?>
<?php
if (!empty($_POST)){
include('repository/userRepository.php');
$username = $_POST['username'];
$password = $_POST['password'];
$password_repeat = $_POST['password_repeat'];
$uniqueId = registerUser($conn, $username, $password, $password_repeat);
if($uniqueId){
// 1 hour cookie to store userLogged username
setcookie("userLogged", $uniqueId, time()+3600);
$notification = [
"type" => "success",
"message" => "Account ".$username." registered"
];
}else{
$notification = [
"type" => "error",
"message" => "Cannot register user account. Maybe your username isn't very original"
];
}
}
?>
<body>
<main class="layout-wrapper">
<h1>Register</h1>
<?php if(isset($notification)){ ?>
<div class="alert--<?php echo($notification['type']) ?>">
<?php echo($notification['message']) ?>
</div>
<?php } ?>
<form action="signup.php" method="post">
<label for="username"></label>
<input name="username" id="username" type="text" value="<?php echo $username ?>" placeholder="Username">
<label for="password"></label>
<input name="password" id="password" type="password" value="" placeholder="password">
<label for="password_repeat"></label>
<input name="password_repeat" id="password_repeat" type="password" value="" placeholder="password">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</main>
<?php
include('partial/footer.php');
?>
</body>
</html>