-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistrate.php
32 lines (31 loc) · 916 Bytes
/
registrate.php
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
require_once "uvod.php";
?>
<html>
<head>
<title>Registrace uživatele</title>
</head>
<body>
<?php
require_once "dbopen.php";
if ($_SERVER['REQUEST_METHOD']=="POST") { // do stránky jsme vlezli metodou POST
// Tady vložíme uživatele do db
$pass_hash = password_hash($_POST["fpass"], PASSWORD_DEFAULT);
$sql="INSERT INTO `uzivatele` (`user`, `pass`, `prava`)
VALUES ('$_POST[fuser]', '$pass_hash', 1)";
$result = $conn->query($sql);
$conn->close();
//automatický skok na index.php
header('Location: index.php');
} else { // do stránky jsme vlezli metodou GET - vypíšeme formulář
echo "<form method=\"POST\" action=\"registrate.php\">
Username:
<input type=\"text\" name=\"fuser\"><br>
Password:
<input type=\"password\" name=\"fpass\"><br><br>
<input type=\"submit\" value=\"Registrovat\">
</form>";
}
?>
</body>
</html>