summaryrefslogtreecommitdiff
path: root/lib/account/new.php
blob: c06083e2a32cce09c9b65a0041d79851dc9484f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

$title = "Register";

$login = "";
if (isset($_POST['login']) && isset($_POST['pw1']) && isset($_POST['pw2'])) {
	$login = esca($_POST["login"]);
	$pw1 = esc($_POST["pw1"]);
	$pw2 = esc($_POST["pw2"]);
	if ($login == "") {
		$error = "You must enter a username.";
	} else if ($pw1 != $pw2) {
		$error = "You must enter twice the same password.";
	} else if ($pw1 == "") {
		$error = "You must enter a password";
	} else {
		sql("INSERT INTO account(login, password) VALUES('" . escs($login) . "', PASSWORD('$pw1'))");
		$message = "Your account has been created. Please log in now.";
		$url = $homepage;
		require("tpl/account/login.php");
	}
}

$form_message = "Please fill in the following form to create an account :";
$fields = array(
	array("label" => "Username : ", "name" => "login", "value" => $login),
	array("label" => "Password : ", "name" => "pw1", "type" => "password"),
	array("label" => "Confirm password : ", "name" => "pw2", "type" => "password")
	);
$validate = "Create an account";

require("tpl/general/form.php");