· 9 years ago · Dec 21, 2016, 10:25 AM
1<? require 'connect.php'; // <--- Zwykłe logowanie do mysqli ?>
2<!DOCTYPE html>
3<html>
4<head>
5 <title> Rejestracja </title>
6 <link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css" />
7 <link rel="stylesheet" type="text/css" href="../styleR.css" />
8 <script type="text/javascript" src="../scripts/jquery.js"></script>
9 <script type="text/javascript" src="../scripts/script.js"></script>
10 <script src='https://www.google.com/recaptcha/api.js'></script>
11</head>
12<body>
13 <div class="register">
14
15 <h3> Panel rejestracji </h3>
16
17 <form method="post" class="form-horizontal">
18 <div class="form-group">
19 <label for="inputEmail3" class="col-sm-2 control-label">Login</label>
20 <div class="col-sm-10">
21 <input type="text" class="form-control" name="login" id="inputEmail3" placeholder="Podaj Login" autofocus>
22 </div>
23 </div>
24 <div class="form-group">
25 <label for="inputPassword3" class="col-sm-2 control-label">Hasło</label>
26 <div class="col-sm-10">
27 <input type="password" class="form-control" name="pass" id="inputPassword3" placeholder="Podaj Hasło">
28 </div>
29 </div>
30 <div class="form-group">
31 <label for="inputPassword3" class="col-sm-2 control-label">Email</label>
32 <div class="col-sm-10">
33 <input type="email" class="form-control" id="inputPassword3" name="email" placeholder="Podaj E-mail">
34 </div>
35 </div>
36 <center><div class="g-recaptcha" id="capcha" name="regulamin" data-sitekey="6Lc6Lw8UAAAAAPDrS5DExUGcUvaYH65AmAGjt-LP"></div></center>
37 <div class="form-group">
38 <div class="col-sm-offset-2 col-sm-10">
39 <input type="submit" name="send" value="Zarejestruj siÄ™!" class="btn btn-block btn-default">
40 </div>
41 </div>
42 </form>
43 </div>
44</body>
45
46 <?php
47
48 $login = htmlspecialchars(htmlentities($_POST['login']));
49
50 $pass = $_POST['pass'];
51
52 $pass_converted = password_hash($_POST['pass'], PASSWORD_DEFAULT);
53
54 $email = htmlspecialchars(htmlentities($_POST['email']));
55
56 $secret_key = '6Lc6Lw8UAAAAAMimyct3sz44DsTGsMYHoiTiqyQZ';
57
58 $check = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_key."&response=".$_POST['g-recaptcha-response']);
59
60 $response = json_decode($check);
61
62 if (isset($_POST['send'])) {
63
64 if (!empty( $login ) && !empty( $pass ) && !empty( $email )) {
65
66 if ( $response->success == true){
67 if( $result = $mysqli->query("select * from users") ){
68
69 $row = $result->fetch_assoc();
70
71 if($login == $row['Login'] || $email == $row['Email']){
72
73 echo '<h4 style="color: red;"> Podany użytkownik już istnieje! </h4>';
74
75 } else {
76
77 if ($stmt = $mysqli->query ("insert into users values ( null, '$login', '$pass_converted', '$email', now())")) {
78 echo '<h4 style="color: green;"> Zarejestrowałeś się poprawnie! </h4>';
79 echo '<a href="../index.php"> Wróc do strony głównej </a>';
80 } else {
81 echo '<h4 style="color: red; margin-left: 5px;"> Błąd zapytania! </h4>';
82 }
83 }
84 }
85 } else {
86 echo '<h4 style="color: red;"> Wybacz, ale botów nie wpuszczamy </h4>';
87 }
88 } else {
89 echo '<h4 style="color: red; margin-left: 5px;"> Uzupełnij wymagane pola! </h4>';
90 }
91 }
92 ?>
93
94</html>