-
Notifications
You must be signed in to change notification settings - Fork 30
/
registerPlayerHandle.php
121 lines (110 loc) · 5.47 KB
/
registerPlayerHandle.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
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
<?php
include "connect.php";
if (isset($_POST['indiReg'])){
$name = $_POST['name'];
$email = $_POST['email'];
$clg = $_POST['clg'];
if($clg == "other"){
$clgid = $_POST['clgid'];
$oth_clg_name = $_POST['oth_clg_name'];
}
else{
$oth_clg_name = null;
$clgid = $_POST['clgid'];
}
$gen = $_POST['gen'];
$phno = $_POST['phone_no'];
$pass = $_POST['create_password'];
$conf_pass = $_POST['confirm_password'];
//Connecting to database
include "connect.php";
// Create a connection
// $conn = mysqli_connect($servername, $username, $password, $database);
// Die if connection was not successful
if (!$conn){
die("Sorry we failed to connect: ". mysqli_connect_error());
}
else{
// Sql query to be executed
$sql = "SELECT * FROM `participant`";
$result = mysqli_query($conn, $sql);
$unique = "true";
//To check if the email is unique
//fetching the rows from the begining and checking if same email exists
while($check = mysqli_fetch_assoc($result))
{
//$cur_email -> email of current row
$cur_email = $check['Email'];
//checking
if($email == $cur_email)
{
//if same email exists already then display a message
echo '<div class="alert alert-success alert-dismissible show" role="alert" style="position:absolute; top:75px; width:100%; color:red; background: #ff000020;" >
<strong> This Email Id is already Registered. Please use another email.</strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">x</span>
</button>
</div>';
$unique = "false";
break;
}
}
//Add the details to database if the email is unique
if($unique == "true"){
while(true){
//Generating Infinito ID
$infno = rand(10000,99999);
//Infinito ID
$infid = "INF". $infno;
$sql = "SELECT * FROM `participant`";
$result = mysqli_query($conn, $sql);
$unique = "true";
//To check if the email is unique
//fetching the rows from the begining and checking if same email exists
while($check = mysqli_fetch_assoc($result))
{
//$cur_infid -> email of current row
$cur_infid = $check['InfId'];
//checking
if($infid == $cur_infid)
{
$unique = "false";
break;
}
}
if($unique == "true")
{
break;
}
}
$to = $email;
$subject = "Infinito 2021 ID.";
$message = "Hello ".$name.",<br>Thank you for registering.<br>".
"Your Infinito 2021 ID is <strong>".$infid."</strong>".
"<br>Confirm your registration by entering this ID.".
"<br>Kindly note your Infinito ID, it will be required to register for any events.".
"Your Infinito ID is your unique verification ID for the fest.<br>".
"Wish you a great time ahead.".
"<br><br>".
"Regards,<br>".
"Team Infinito";
//$headers = 'From: [email protected]' . "\r\n" .
//'MIME-Version:1.0'. "\r\n" .
//'Content-Type: text/html; charset=utf-8';
//require 'mail.php';
//**************Redirecting to the confirmation page and inserting there********//
session_start();
$hash=password_hash($pass , PASSWORD_DEFAULT);
if($clg == "other")
{
$clg = $oth_clg_name;
}
$sql = "INSERT INTO `participant` (`Serial Number`,`InfId`, `Name`, `Email`,`Password`, `College`, `ID`, `Phone Number`, `Gender`, `dt`) VALUES (NULL, '$infid' , '$name', '$email', '$hash', '$clg', '$clgid', '$phno', '$gen', current_timestamp())";
$result = mysqli_query($conn, $sql);
$_SESSION['conf_infid'] = $infid;
header('location:confirmation.php');
exit;
}
}
}
?>