fboard/fboard/etc/cgi/register.php

42 lines
918 B
PHP

<?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($username) < 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);
?>