-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrejestracja.php
71 lines (61 loc) · 2.6 KB
/
rejestracja.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once 'vendor/autoload.php';
session_start();
use Ibd\Uzytkownicy;
use Valitron\Validator;
$uzytkownicy = new Uzytkownicy();
$v = new Validator($_POST);
if (isset($_POST['zapisz'])) {
$v->rule('required', ['imie', 'nazwisko', 'adres', 'email', 'login', 'haslo']);
if ($v->validate()) {
// brak błędów, można dodać użytkownika
$uzytkownicy->dodaj($_POST);
header("Location: index.php?msg=1");
exit();
}
}
include 'header.php';
?>
<h1>Rejestracja</h1>
<?php if ($v->errors()): ?>
<div class="alert alert-danger">
<strong>Wystąpił błąd</strong>
<ul>
<?php foreach ($v->errors() as $err): ?>
<li><?=implode('<br>', $err) ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<form method="post" action=""">
<div class="form-group">
<label for="imie">Imię</label>
<input type="text" id="imie" name="imie" class="form-control <?= $v->errors('imie') ? 'is-invalid' : '' ?>" value="<?= $_POST['imie'] ?? '' ?>"/>
</div>
<div class="form-group">
<label for="nazwisko">Nazwisko</label>
<input type="text" id="nazwisko" name="nazwisko" class="form-control <?= $v->errors('nazwisko') ? 'is-invalid' : '' ?>" value="<?= $_POST['nazwisko'] ?? '' ?>"/>
</div>
<div class="form-group">
<label for="adres">Adres</label>
<input type="text" id="adres" name="adres" class="form-control <?= $v->errors('adres') ? 'is-invalid' : '' ?>" value="<?= $_POST['adres'] ?? '' ?>"/>
</div>
<div class="form-group">
<label for="telefon">Telefon</label>
<input type="text" id="telefon" name="telefon" class="form-control <?= $v->errors('telefon') ? 'is-invalid' : '' ?>" value="<?= $_POST['telefon'] ?? '' ?>"/>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" id="email" name="email" class="form-control <?= $v->errors('email') ? 'is-invalid' : '' ?>" value="<?= $_POST['email'] ?? '' ?>"/>
</div>
<div class="form-group">
<label for="login">Login</label>
<input type="text" id="login" name="login" class="form-control <?= $v->errors('login') ? 'is-invalid' : '' ?>" value="<?= $_POST['login'] ?? '' ?>"/>
</div>
<div class="form-group">
<label for="haslo">Hasło</label>
<input type="password" id="haslo" name="haslo" class="form-control <?= $v->errors('haslo') ? 'is-invalid' : '' ?>" />
</div>
<input type="submit" name="zapisz" id="zapisz" class="btn btn-primary" value="Zarejestruj się" /><br/><br/>
</form>
<?php include 'footer.php'; ?>