-
Notifications
You must be signed in to change notification settings - Fork 128
/
logowanie.php
86 lines (80 loc) · 1.98 KB
/
logowanie.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Forum o psach</title>
<link rel="stylesheet" href="styl4.css" />
</head>
<body>
<div id="baner">
<h1>Forum wielbicieli psów</h1>
</div>
<div id="lewy">
<img src="obraz.jpg" alt="foksterier" />
</div>
<div id="prawy1">
<h2>Zapisz się</h2>
<form action="logowanie.php" method="post">
<label>
login:
<input type="text" name="login" /><br/>
</label>
<label>
hasło:
<input type="password" name="haslo" /><br/>
</label>
<label>
powtórz hasło:
<input type="password" name="powhaslo" /><br/>
</label>
<button>Zapisz</button>
</form>
<?php
$con = mysqli_connect('localhost', 'root', '', 'psy');
if(isset($_POST['login']) && isset($_POST['haslo']) && isset($_POST['powhaslo'])) {
$login = $_POST['login'];
$haslo = $_POST['haslo'];
$powhaslo = $_POST['powhaslo'];
$blad = FALSE;
if($login == '' || $haslo == '' || $powhaslo == '') {
echo "<p>wypełnij wszystkie pola</p>";
$blad = TRUE;
}
$kw = "SELECT login FROM uzytkownicy;";
$res = mysqli_query($con, $kw);
while($tab = mysqli_fetch_row($res)) {
if($login == $tab[0]) {
echo "<p>login występuje w bazie danych, konto nie zostało dodane</p>";
$blad = TRUE;
break;
}
}
if($haslo != $powhaslo) {
echo "<p>hasła nie są takie same, konto nie zostało dodane</p>";
$blad = TRUE;
}
if($blad == FALSE) {
$szyfr = sha1($haslo);
$kw = "INSERT INTO uzytkownicy VALUES (NULL, '$login', '$szyfr');";
mysqli_query($con, $kw);
echo "<p>Konto zostało dodane</p>";
}
}
mysqli_close($con);
?>
</div>
<div id="prawy2">
<h2>Zapraszamy wszystkich</h2>
<ol>
<li>właścicieli psów</li>
<li>weterynarzy</li>
<li>tych, co chcą kupić psa</li>
<li>tych, co lubią psy</li>
</ol>
<a href="regulamin.html">Przeczytaj regulamin forum</a>
</div>
<div id="stopka">
Stronę wykonał: Chriskyy#0181
</div>
</body>
</html>