-
Notifications
You must be signed in to change notification settings - Fork 0
/
certGeneration.php
190 lines (134 loc) · 5.74 KB
/
certGeneration.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
//------------------------------>> CENTRALIZED TECHFEST NAME WITH YEAR
require_once "config/techfestName.php";
//------------------------------>> DB CONFIG
require_once "config/configPDO.php";
// ----------------------------->> STARTING SESSION
session_start();
//---------------------------------->> CHECKING USER
if (!isset($_SESSION['user'])) {
header("location:login.php");
}
if (isset($_POST['event1'])) {
$_SESSION["buttonEvent"] = htmlspecialchars($_POST['event1']);
$buttonEvent = $_SESSION["buttonEvent"];
} else {
$buttonEvent = $_SESSION["buttonEvent"];
}
$email = $_SESSION['user'];
try {
// ----------------------------->> EXTRACT ALL INFO. ABOUT USER & HIS/HER PARTICIPATION
$sql = "SELECT * FROM user_information INNER JOIN event_information ON
user_information.email= event_information.email
WHERE user_information.email = :email AND event_information.event = :buttonEvent";
$result = $conn->prepare($sql);
$result->bindValue(":email", $email);
$result->bindValue(":buttonEvent", $buttonEvent);
$result->execute();
$row = $result->fetch(PDO::FETCH_ASSOC);
$firstName = $row['firstName'];
$lastName = $row['lastName'];
$department = $row['departmentName'];
$collegeName = $row['collegeName'];
$prize = $row['prize'];
$validate = $row['certificateId'];
$event = $row['event'];
// ------------------------------------>> DIFF. BACKGROUND FOR DIFFERENT DEPARTMENT
$sql1 = "SELECT * from events_details_information where eventName = '$buttonEvent'";
$result1 = $conn->prepare($sql1);
$result1->bindValue(":buttonEvent", $buttonEvent);
$result1->execute();
$row1 = $result1->fetch(PDO::FETCH_ASSOC);
$certificateDepartment = $row1['eventDepartment'];
} catch (PDOException $e) {
echo "<script>alert('We are sorry, there seems to be a problem with our systems. Please try again.');</script>";
# Development Purpose Error Only
echo "Error " . $e->getMessage();
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $techfestName ?> | CERTIFICATE</title>
<!-- Certificate CSS-->
<link rel="stylesheet" href="css/certificate.css">
<link rel="stylesheet" href="css/certificateShodh.css">
<style type="text/css">
.cert {
<?php
if ($certificateDepartment === "Electronics and Telecommunication") {
echo "background-image: url(images/cert-images/extc-cert.jpg);";
} elseif ($certificateDepartment === "Chemical") {
echo "background-image: url(images/cert-images/chem-cert.jpg);";
} elseif ($certificateDepartment === "Civil") {
echo "background-image: url(images/cert-images/civil-cert.jpg);";
} elseif ($certificateDepartment === "Computer") {
echo "background-image: url(images/cert-images/comp-cert.jpg);";
} else {
echo "background-image: url(images/cert-images/mech-cert.jpg);";
}
?>
margin: auto;
width: 1200px;
height: 750px;
background-repeat: no-repeat;
background-size: 1200px 750px;
}
.mainContent {
font-family: Arial, Helvetica, sans-serif !important;
font-size:25px !important;
}
</style>
</head>
<body onload="makeCode()">
<button id="btnPrint">Save as PDF</button>
<section class="cert">
<!--Content of Certificate-->
<p class="mainContent"> Mr./Ms.<span><?php echo $firstName ?></span> <span><?php echo $lastName ?></span> of
<span><?php echo $department ?></span> Department from <br><br>
<span><?php echo $collegeName ?></span> College has Participated in <span><?php echo $event ?></span> <br/> <br/>
Event of <?php echo $techfestName ?> held during <?php echo $techfestDate ?> at GIT, Lavel & Won <span><?php echo $prize ?></span> Prize. </p>
<span id="qrcode" class="center" style="width:100px; height:100px; margin-top:10px;"></span>
<p class="footer-text">
<b><span class="validate">Certficate Id: <?php echo $validate ?></span><br>
This is computer generated Certificate does not required any signature, Verify certificate at<br>
<a target="_blank"
href="http://localhost/EBA/verifyCertificate.php?certificateId=<?php echo $validate ?>">
http://localhost/EBA/verifyCertificate.php?certificateId=<?php echo $validate ?>
</a> or Go to Certificate Verification Page.</b>
</p>
</section>
<!--Jquery-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- JS Variables to Convert data into QR Code-->
<script type="text/javascript">
let a = "<?php echo $firstName ?>";
let b = "<?php echo $lastName ?>";
let c = "<?php echo $department ?>";
let d = "<?php echo $event ?>";
let e = "<?php echo $prize ?>";
let f = "<?php echo $validate ?>";
</script>
<!-- QR Code JS Library-->
<script type="text/javascript" src="js/qrcode.min.js"></script>
<!-- Convert JS Variable data into QR Code takes input above JS Variable-->
<script type="text/javascript" src="js/php-certQrCode.js"> </script>
<!--Script of Button to Save PDF-->
<script type="text/javascript">
$("#btnPrint").live("click", function () {
var printButton = document.getElementById("btnPrint");
//Set the print button visibility to 'hidden'
printButton.style.visibility = 'hidden';
//Print the page content
window.print();
});
</script>
<script>
if (window . history . replaceState) {
window . history . replaceState(null, null, window . location . href);
}
</script>
<!-- Close Database Connection -->
<?php $conn = null;?>
</body>
</html>