-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify-register.php
44 lines (40 loc) · 1.34 KB
/
verify-register.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
<?php
// include User file
include_once('User.php');
// Object creation
$userdata=new User();
// Your code here to handle a successful verification
if(isset($_POST['submit']))
{
require('recaptcha/constant.php');
// Posted Values
$fname=$_POST['firstName'];
$lname=$_POST['lastName'];
$uname=$_POST['userName'];
$uemail=$_POST['emailAddress'];
$upass=md5($_POST['password']);
//reCAPTCHA validation
if (isset($_POST['g-recaptcha-response'])) {
require('recaptcha/component/recaptcha/src/autoload.php');
$recaptcha = new \ReCaptcha\ReCaptcha(SECRET_KEY);
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if (!$resp->isSuccess()) {
$output = json_encode(array('type'=>'error', 'text' => '<b>Captcha</b> Validation Required!', 'out' => $_POST['g-recaptcha-response'], 'remote-add' => $_SERVER['REMOTE_ADDR']));
die($output);
}
}
//Function Calling
$sql=$userdata->registerUser($fname,$lname,$uname, $uemail,$upass);
if($sql)
{
// Message for successfull insertion
echo "<script>alert('Registration successfull.');</script>";
echo "<script>window.location.href='login.php'</script>";
}
else
{
// Message for unsuccessfull insertion
echo "<script>window.location.href='register.php'</script>";
}
}
?>