This commit is contained in:
filip 2021-01-22 19:58:07 +01:00
parent c14005d9bd
commit 43799c45a3
3 changed files with 57 additions and 11 deletions

View File

@ -0,0 +1,41 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data, ENT_QUOTES);
return $data;
}
$password = test_input($_POST["password"]);
if ($password != $_POST["password"]) {
return; //the password is not the same as the one given after sanitizing
}
$password2 = test_input($_POST["password2"]);
if ($password != $password2){
return; // the passwords do not match
}
$username = test_input($_POST["username"]);
$pattern = "/[^a-zA-z0-9_\-]/"; //remove any character that is not: a-z A-Z _ -
$username = preg_replace($pattern, "", $username);
if (strlen($usename) < 2) {
return;
}
//there needs to be a way to check if username is allready taken
$base_dir = "./../..";
$user_dir = $base_dir . "/user/" . username;
echo user_dir;
mkdir($user_dir);
?>

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<h1>Register new user</h1>
<p>You might want to review the source code of fBoard before you register</p>
<form action="../cgi/register.php">
<input type="text" id="user_name" required>
<input type="password" id="password" required>
<input type="password" id="verify_password" required>
</form>
</body></html>

16
fboard/register/index.php Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<h1>Register new user</h1>
<p>You might want to review the source code of fBoard before you register</p>
<?php $script = "../etc/cgi/register.php"; //script location
?>
<form action="<?php echo $script; ?>" method="post">
User name: <input type="text" id="username" required><br>
Full name: <input type="text" id="full_name"><br>
Email: <input type="text" id="email"><br>
Password: <input type="password" id="password" required><br>
Verify password: <input type="password" id="password2" required><br>
<input type="submit">
</form>
</body></html>