-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.php
executable file
·162 lines (124 loc) · 5.1 KB
/
entry.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
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
<?php require 'header.php'; ?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(isset($_POST['daAction'])){
$sql = '';
if(strcasecmp($_POST["daAction"], "create_raffle_entry") == 0){
$sql = "insert into raffle.entry(campaign, firstname, lastname, email) values ('".$_POST['campaign']."','".$_POST['firstname']."', '".$_POST['lastname']."', '".$_POST['email']."')";
}
if(strlen($sql) > 0){
//error_log("c3p0: ".$sql);
$mySQL = new db_mysql();
mysqli_query($mySQL->connection, $sql);
$mySQL->disconnect();
}
}
}
?>
<link rel="stylesheet" href="/css/jstree/style.min.css" />
<link rel="stylesheet" href="/css/contextMenu/jquery.contextMenu.css" />
<link rel="stylesheet" href="/css/jquery_ui/jquery-ui.min.css" />
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jstree.js"></script>
<script src="/js/jquery.contextMenu.js"></script>
<script src="/js/jquery-ui-1.11.4/jquery-ui.min.js"></script>
<div id="campaign-form" title="Raffle entry form" style="display: none;">
<form id='campaignEntryForm' name='campaignEntryForm' method="post">
<input type="hidden" name="campaign" id="campaign">
<fieldset>
<table>
<tr>
<td align='right'><label for="firstname">firstname</label></td>
<td><input type="text" name="firstname" id="firstname"></td>
</tr>
<tr>
<td align='right'><label for="lastname">lastname</label></td>
<td><input type="text" name="lastname" id="lastname"></td>
</tr>
<tr>
<td align='right'><label for="email">e-mail</label></td>
<td><input type="text" name="email" id="email"></td>
</tr>
<tr>
<td colspan='2' align='center'>
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
</td>
</tr>
</table>
</fieldset>
</form>
</div>
<?php
if(isset($_GET["campaign"])){
$mySQL = new db_mysql();
$sql = "select * from raffle.campaign where href='".$_GET["campaign"]."'";
$resultset = mysqli_query($mySQL->connection, $sql);
if(mysqli_num_rows($resultset) == 0){
echo "<script>document.write('No raffle association for the requested campaign id: '+location.href.split('?')[1])</script>";
}
else{
while ($row = mysqli_fetch_object($resultset)) {
echo "<script>document.getElementById('campaign').value = '".$row->id."';</script>";
echo '<a href="javascript: displayForm();"><img width="800" height="600" src="data:image;base64,'.$row->image_000.'"></a>';
}
}
mysqli_free_result($resultset);
$mySQL->disconnect();
}
?>
<script>
function displayForm(){
//$("#campaign-form").show();
var dialog, daButtons, form;
daButtons = {
Enter: function(){
$('input').removeAttr('disabled');
submitEntryRaffleEntry();
},
Cancel: function(){
dialog.dialog("close");
}
};
dialog = $("#campaign-form").dialog({
autoOpen: false,
width: '580',
modal: true,
buttons: daButtons,
close: function(){
//form[ 0 ].reset();
//allFields.removeClass("ui-state-error");
}
});
form = dialog.find("#campaignEntryForm").on("submit", function(event){
event.preventDefault();
$('input').removeAttr('disabled');
submitEntryRaffleEntry();
});
dialog.dialog("open");
function submitEntryRaffleEntry(){
var daData = new FormData(document.getElementById("campaignEntryForm"));
daData.append("daAction", "create_raffle_entry");
var request = $.ajax({
method: "POST",
data: daData,
cache: false,
contentType: false,
processData: false
});
grayOut(true);
request.done(function(msg){
//console.log(msg);
alert("Entry Accepted. Please check your email for Raffle entry confirmation.");
top.grayOut(false);
location.reload();
});
request.fail(function(jqXHR, textStatus){
alert("Request failed: " + textStatus);
top.grayOut(false);
});
dialog.dialog("close");
}
}
</script>
<?php include 'footer_nested.php'; ?>