-
Notifications
You must be signed in to change notification settings - Fork 0
/
rejestracja.php
80 lines (74 loc) · 3.01 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
72
73
74
75
76
77
78
79
80
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="r-form">
<h1 style="text-align: center;">REJESTRACJA</h1>
</div>
<div id="r-form-table">
<form action="" method="post">
<table>
<tr><td>Login: </td><td><input type="text" name="login" pattern="{3,}" title="Must contain 3 or more characters"></td></tr>
<tr><td>Hasło: </td><td><input type="password" name="pass" pattern="([A-Za-z0-9]){6,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 6 or more characters"></td></tr>
<tr><td>Powtórz hasło: </td><td><input type="password" name="passw" pattern="([A-Za-z0-9]){6,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 6 or more characters"></td></tr>
<tr><td>Email: </td><td><input type="email" name="email"></td></tr>
<tr><td>Potwórz Email: </td><td><input type="email" name="emailv"></td></tr>
<tr><td></td><td><input type="submit" class="submit1"></td></tr>
</table>
</form>
<a href="login.php">Posiadasz już konto? <span id="lll"><u>Zaloguj się</u></span></a>
</div>
<?php
include 'config.php';
class Register
{
public $login;
public $pass;
public $email;
public $ip;
public function __construct($login,$pass,$passw,$email,$emailv,$ip)
{
if($pass==$passw && $email==$emailv)
{
$this->login=$login;
$this->pass=md5($pass);
$this->email=$email;
$this->ip=$ip;
}
else
{
echo '<span style="text-align:center;"><b>Podane dane nie zgadzają się.</b></span>';
}
}
public function db_add()
{
global $conn;
$q='INSERT INTO uzytkownicy VALUES (NULL,"'.$this->login.'","'.$this->pass.'","'.$this->email.'","'.$this->ip.'")';
$conn->query($q) or die ('Wystąpił błąd przy wykonaniu kwerendy.');
echo '<span style="text-align: center;"><b>Dodano do bazy.</b></span>';
}
public function db_add_auth()
{
if($this->login=='' || $this->pass=='' || $this->email='')
{
return 0;
}
else return 1;
}
}
if(!empty($_POST['login']) && !empty($_POST['pass']) && !empty($_POST['passw']) && !empty($_POST['email']) && !empty($_POST['emailv'])) {
$o1 = new Register($_POST['login'], $_POST['pass'], $_POST['passw'], $_POST['email'], $_POST['emailv'], $_SERVER['REMOTE_ADDR']);
if ($o1->db_add_auth() == 1) $o1->db_add();
else echo('<span style="text-align: center;"><b>Proszę podać poprawne dane.</b></span>');
}
else{
echo '<span style="text-align: center;"><b>Proszę uzupełnić dane.</b></span>';
}
?>
<footer>
<a href="https://github.com/zdinozi" target="_blank"><img src="github-ww.png" style="width: 50px; height: 50px;"></a>
<a href="https://www.linkedin.com/in/wiktor-banasiak-672425222/" target="_blank"><img src="linkedin.png" style="width: 50px; height: 50px;"></a>
</footer>
</body>
</html>