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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
<? include('_init.php');?> <? if(@$_POST['action']=='registration'){ ini_set('display_errors',0); if (!function_exists('call_curl')) { function call_curl($url, $postData, $post) { if (!empty($post)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $result = curl_exec($ch); curl_close($ch); } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $result = curl_exec($ch); curl_close($ch); } return $result; } } $lang = $data['lang']; $url = "https://www.google.com/recaptcha/api/siteverify"; $post_data = array("secret" => '6Ld8JxoTAAAAAOQU6SZoYVFRJ_ioLc_gQnb-0m6Y', "response" => $_POST["g-recaptcha-response"]); $result = call_curl($url, $post_data, 1); $result_array = json_decode($result, true); if (!$result_array["success"]) { echo '<script>alert("驗證碼錯誤");location.href="login.php"</script>'; }else{ $data = $_POST; $sql = 'INSERT INTO `member` (`name`,`email`,`password`,`is_email`,`createdate`,`status`,`deleted`) values (?,?,?,?,?,?)'; $parameters = array($data['name'],$data['email'],md5($data['password']),$data['is_email'],date('Y-m-d'),1,0); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); } if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); } echo '<script>alert("註冊成功");location.href="login.php"</script>'; exit(); } exit(); }?> <!DOCTYPE html> <html lang="<?=$lang?>"> <head> <? include('_head.php');?> <link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/form-elements.css"> <link rel="stylesheet" href="../css/loginStyle.css"> <script src='https://www.google.com/recaptcha/api.js'></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(function(){ $('#login-form').submit( function(){ return false; } ); }) function submitRegistration(){ var error = false; $.post('../_ajax.php', { ajax: 'cheackMember', email: $('#registration-form input[name="email"]').val() }, function(json) { var str = JSON.parse(json); $('#registration-form input').removeClass('failed'); if(!$('#registration-form input[name="name"]').val()){ $('#registration-form input[name="name"]').addClass('failed'); error = true; } if(!$('#registration-form input[name="email"]').val()){ $('#registration-form input[name="email"]').addClass('failed'); error = true; }else{ if(! /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/.test($('#registration-form input[name="email"]').val())){ $( '#registration-form input[name="email"]' ).addClass('failed'); error = true; }else{ if(str.status == false){ $( '#registration-form input[name="email"]' ).addClass('failed'); error = true; } } } if(!$('#registration-form input[name="password"]').val()){ $( "#registration-form input[name='password']" ).addClass('failed'); error = true; } if(!$('input[name="re_password"]').val()){ //msg += '<li>Comfirm Password - Mandatory Field</li>'; $( "#registration-form input[name='re_password']" ).addClass('failed'); error = true; } if($('#registration-form input[name="password"]').val() && $('#registration-form input[name="re_password"]').val()){ if($('input[name="password"]').val() != $('input[name="re_password"]').val()){ //msg += '<li>Comfirm Password - Must Same with Password</li>'; $( "#registration-form input[name='re_password']" ).addClass('failed'); error = true; } } if(error == false){ $('#registration-form').submit(); console.log('a'); return true; } }); } </script> </head>
<body> <!-- Top content --> <div class="top-content"> <div class="inner-bg"> <div class="container"> <div class="row"> <div class="col-sm-8 col-sm-offset-2 text"> <h1><strong><a href="index.html">中華青年宇航學社</a></strong></h1> <div class="description"> <p> 宗旨: 對中國航天發展過程認識及了解,從而對國民身份的認同 <br> 對象:青少年,香港中小學生,大學生,在職青年 </strong> </p> </div> </div> </div> <div class="row"> <div class="col-sm-5"> <div class="form-box"> <div class="form-top"> <div class="form-top-left"> <h3>登入</h3> <p>請輸入用戶名稱及密碼:</p> </div> <div class="form-top-right"> <i class="fa fa-lock"></i> </div> </div> <div class="form-bottom"> <form role="form" action="" method="post" class="login-form"> <div class="form-group"> <label class="sr-only" for="form-username">Username</label> <input type="text" name="form-username" placeholder="用戶名稱..." class="form-username form-control" id="form-username"> </div> <div class="form-group"> <label class="sr-only" for="form-password">Password</label> <input type="password" name="form-password" placeholder="密碼..." class="form-password form-control" id="form-password"> </div> <button type="submit" class="btn">登入</button> </form> </div> </div> </div> <div class="col-sm-1 middle-border"></div> <div class="col-sm-1"></div> <div class="col-sm-5"> <div class="form-box"> <div class="form-top"> <div class="form-top-left"> <h3>註冊</h3> <p>請輸入以下資料以便註冊:</p> </div> <div class="form-top-right"> <i class="fa fa-pencil"></i> </div> </div> <div class="form-bottom"> <form role="form" action="" method="post" id="registration-form"> <input type="hidden" name="action" value="registration"/> <div class="form-group"> <input type="text" name="name" placeholder="用戶名稱..." class="form-first-name form-control"> </div> <div class="form-group"> <input type="text" name="email" placeholder="電郵地址..." class="form-email form-control" > </div> <div class="form-group"> <input type="password" name="password" placeholder="密碼..." class="form-last-name form-control"> </div> <div class="form-group"> <input type="password" name="re_password" placeholder="確認密碼..." class="form-last-name form-control" > </div> <div class="form-group"> <label><input type="checkbox" name="is_email" value="1" checked style="margin-right:5px;"/>我特此同意接收市場推廣的資料、資訊溝通、推銷廣告、通訊及任何中華青年宇航學社 及其相關公司、附屬公司、子公司及聯營公司等關於產品及服務的傳訊。</label> </div> <div class="form-group"> <div class="g-recaptcha" data-sitekey="6Ld8JxoTAAAAAJRyv8SC2sG8UMn93LguA0lb0e7j"></div> </div> <button type="button" class="btn" onClick="submitRegistration()">註冊</button> </form> </div> </div> </div> </div> </div> </div> </div> </body> </html>
|