-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg_action.php
53 lines (51 loc) · 1.89 KB
/
reg_action.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
<?php
session_start();
$captcha = "" ;
include "connection.php";
if(isset($_POST['submit'])) {
/*if (isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
$error = "Please check captcha too";
include ('register.php');
exit();
}
$secretKey = "6LeD3hEUAAAAADNeeaGRfKmABjn1gnsXxrpdTa2J";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
$error = "You are spammer !";
}*/
$name = mysqli_real_escape_string($con, $_POST['firstname']);
$name2 = mysqli_real_escape_string($con,$_POST['lastname']);
$name3 = mysqli_real_escape_string($con,$_POST['username']);
$pass = mysqli_real_escape_string($con,$_POST['password']);
$sq = mysqli_query($con, 'SELECT username FROM loginusers WHERE username="'.$_POST['username'].'"');
$exist = mysqli_num_rows($sq);
if($exist==1){
$nam="<center><h4><font color='#FF0000'>The username already exist, peak another.</h4></center></font>";
unset($username);
include('register.php');
exit();
}
$sql = mysqli_query($con, 'INSERT INTO voters(firstname,lastname,username)
VALUES("'.$_POST['firstname'].'","'.$_POST['lastname'].'","'.$_POST['username'].'")');
if (!$sql) {
die (mysqli_error($con));
}
$sql2 = mysqli_query($con, 'INSERT INTO loginusers(username,password)
VALUES("'.$_POST['username'].'","'.md5($_POST['password']).'")');
if (!$sql2) {
die (mysqli_error($con));
}
else {
echo "Successfully Registered! <a href= 'login.php'>Clich here to Login </a>";
}
}
else {
$error="<center><h4><font color='#FF0000'>Registration Failed Due To Error !</h4></center></font>";
include"register.php";
}
?>