-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventreg.php
81 lines (73 loc) · 2.64 KB
/
eventreg.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
<?php
require 'connect.php';
require 'functions.php';
session_start();
$event = mysqli_real_escape_string($db, $_GET['event']);
$groupid = mysqli_real_escape_string($db, $_GET['groupid']);
if (!isset($_SESSION['userid'])){
$message = array ("status" => "logout", "description" => "You need to log in to register for events");
echo json_encode($message);
die();
}
if (!isset($_GET['deregister'])){
if (!checkIfRegIsPossible($db, $groupid, $event, "events")){
$message = array ("status" => "fail", "description" => "Someone in this Group Already registered with an another group");
echo json_encode($message);
die();
}
$sql = "SELECT * FROM `events` WHERE `groupid`=\"$groupid\"";
$result = executeQuery($db, $sql);
if ($result->num_rows == 0){
$insert_sql = "INSERT INTO `events` (groupid) VALUES (\"$groupid\")";
executeQuery($db, $insert_sql);
}
$update_sql = "UPDATE `events` SET `$event`=\"1\" WHERE `groupid`=\"$groupid\"";
executeQuery($db, $update_sql);
$message = array ("status" => "success", "description" => "You are registered", 'code' => $db->affected_rows);
// require 'events.php';
// $email_to = $_SESSION['email'];
// $name = $_SESSION['name'];
// $subject = "Synergy Event Registration";
// $email_from = "[email protected]";
// $password = "Ri159487263z_";
//
// $body = "Synergy 2016\n\n";
// $body = $body . "You have been registered for the event : " . $events[$event];
// $body = $body . "You Registration ID : " . $groupid;
//
// require("phpmailer/class.phpmailer.php");
// date_default_timezone_set('Etc/UTC');
//
// require 'phpmailer/PHPMailerAutoload.php';
//
// $mail = new PHPMailer;
// $mail->isSMTP();
// $mail->SMTPDebug = 0;
// $mail->Debugoutput = 'html';
// $mail->Host = 'smtp.gmail.com';
// $mail->Port = 587;
// $mail->SMTPSecure = 'tls';
// $mail->SMTPAuth = true;
// $mail->Username = $email_from;
// $mail->Password = $password;
// $mail->setFrom( $email_from, 'Synergy 2016');
// $mail->addReplyTo($email_from, "Synergy 2016");
// $mail->addAddress($email_to, $name);
// $mail->Subject = 'Synergy Events Registration';
// $mail->msgHTML($body, dirname(__FILE__));
// $mail->AltBody = $body;
// if(!$mail->send()) {
// $message['email']="send to ". $email_to;
// }
// else{
// $message['email']="not send";
// }
echo json_encode($message);
}else{
$update_sql = "UPDATE `events` SET `$event`=\"0\" WHERE `groupid`=\"$groupid\"";
executeQuery($db, $update_sql);
$message = array ("status" => "deregistered", "description" => "You are deregistered", 'code' => $db->affected_rows);
echo json_encode($message);
}
$db->close();
?>