-
Notifications
You must be signed in to change notification settings - Fork 1
/
patient_form.php
214 lines (173 loc) · 7.97 KB
/
patient_form.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
echo '<div class="d-none">'; #Bootstrap 'd-none' as mysql_connect is an old syntax.
$conn=mysql_connect('localhost','root',''); #for wampserver/xampserver user
$db=mysql_select_db('dbms_pr');
echo '</div>';
#assinging values to variables
$name=$_POST['fname'];
$roll=$_POST['roll'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$prog=$_POST['prog'];
$branch=$_POST['branch'];
$weight=$_POST['wght'];
$height=$_POST['hght'];
$address=$_POST['H-R'];
$phone=$_POST['pno'];
$email="";
#query to add student's data into database
$qry="INSERT INTO STUDENT(ROLL,NAME,AGE,PROG,BRANCH,HEIGHT,WEIGHT,ADDRESS,PHONE_NUMBER,GENDER) VALUES ('$roll','$name','$age','$prog','$branch','$height','$weight','$address','$phone','$gender')";
$result=mysql_query($qry);
if($result){
$qry="SELECT * FROM TIME WHERE COUNT IS NOT NULL AND COUNT<5";
#if count of any slot is less than 5
$result=mysql_query($qry);
$num = mysql_num_rows($result);
if($num>0){
$row = mysql_fetch_assoc($result);
$pev=$row['COUNT'];
$curr=$pev + 1;
$time=$row['TIME_SLOT'];
$sno=$row['S_NO'];
$day=date("d")+ 1;
$other=date("F Y");
$full_date=date("Y-m-");
$inserted_date=$full_date."".$day;
$qry="UPDATE TIME SET COUNT='$curr' WHERE S_NO='$sno'";
$result1=mysql_query($qry);
echo '<div class="row justify-content-center">
<div class="yellow-box col-8" >
<h3 class="mb-0 text-red">
<center>You have been registered for Covid-19 test.</center>
</h3><br><p class="d-sm-block"><strong>'.$name.'</strong>, you have been registered for the mandatory Covid-19 test. Please report to the campus PHC for your physical test at the given time and date. A mail has been sent to your institute email-id. Kindly wear your mask to the venue.<br> Thank you.</p><p class="d-sm-block">';
echo'<strong><center>Time slot is '.$time.' of '.$day.' '.$other.'</center></strong>';
echo'</div></div>';
$qry="INSERT INTO ALLOTTED_TIME(ROLL,TIMESLOT,DATE) VALUES ('$roll','$time','$inserted_date')";
$result3=mysql_query($qry);
#$email_id=$roll."@iiitdmj.ac.in";
#email stuff-----------------------------------------------------------
echo'<div class="d-none">';
require 'PHPMailerAutoload.php';
require 'cred.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = EMAIL; // SMTP username
$mail->Password = PASS; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
// TCP port to connect to
$mail->setFrom(EMAIL, 'PHC MANAGEMENT');
$mail->addAddress('[email protected]'); // Add a recipient
$mail->addReplyTo(EMAIL);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST['subject'];
$mail->Body = '<div style="border:2px solid red;">'.$name.' YOUR REGISTRATION HAS BEEN <b> CONFIRMED! you have to visit phc at '.$time." at ".$day.' of '.$other.'</b></div>';
$mail->AltBody = $_POST['message'];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
echo'</div>';
//email stuff end-----------------------------------------------------------------
}
else{
//if count is 5 nd next slot is null
$qry="SELECT * FROM TIME WHERE COUNT IS NULL LIMIT 1";
$result=mysql_query($qry);
$num = mysql_num_rows($result);
if($num>0){
while($row1 = mysql_fetch_assoc($result)){
$curr=1;
$time=$row1['TIME_SLOT'];
$sno=$row1['S_NO'];
$day=date("d") + 1;
$other=date("F Y");
$full_date=date("Y-m-");
$inserted_date=$full_date."".$day;
$qry="UPDATE TIME SET COUNT='$curr' WHERE S_NO='$sno'";
$result1=mysql_query($qry);
echo '<div class="row justify-content-center">
<div class="yellow-box col-8" >
<h3 class="mb-0 text-red">
<center>You have been registered for Covid-19 test.</center>
</h3><br><p class="d-sm-block"><strong>'.$name.'</strong>, you have been registered for the mandatory Covid-19 test. Please report to the campus PHC for your physical test at the given time and date. A mail has been sent to your institute email-id. Kindly wear your mask to the venue.<br> Thank you.</p><p class="d-sm-block">';
echo'<strong><center>Time slot is '.$time.' of '.$day.' '.$other.'</center></strong>';
echo'</div></div>';
$qry="INSERT INTO ALLOTTED_TIME(ROLL,TIMESLOT,DATE) VALUES ('$roll','$time','$inserted_date')";
$result3=mysql_query($qry);
//$email_id=$roll."@iiitdmj.ac.in";
//again email stuff-----------------------------------------------------------
echo'<div class="d-none">';
require 'PHPMailerAutoload.php';
require 'cred.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = EMAIL; // SMTP username
$mail->Password = PASS; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
// TCP port to connect to
$mail->setFrom(EMAIL, 'PHC MANAGEMENT');
$mail->addAddress('[email protected]'); // Add a recipient
$mail->addReplyTo(EMAIL);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST['subject'];
$mail->Body = '<div style="border:2px solid red;">'.$name.' YOUR REGISTRATION HAS BEEN <b> CONFIRMED! you have to visit phc at '.$time." at ".$day.' of '.$other.'</b></div>';
$mail->AltBody = $_POST['message'];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
echo'</div>';
//email stuff end---------------------------------------------------
}
}
else {
$qry="DELETE FROM STUDENT WHERE ROLL='$roll'";
$result=mysql_query($qry);
echo '<div class="row justify-content-center">
<div class="yellow-box col-8" >
<h3 class="mb-0 text-red">
<center>No Time slot left, please try again tommorrow.</center>
</h3>
<br>
<p class="d-sm-block"><strong>'.$name.'</strong>, timeslot for tommorow\'s batch has been filled, please try again tommorrow.<br>Thank You.</p><p class="d-sm-block">';
echo'</div></div>';
}
}
}
else{
echo '<div class="row justify-content-center">
<div class="yellow-box col-8" >
<h3 class="mb-0 text-red">
<center>Technical error occured...</center>
</h3>
<br>
<p class="d-sm-block"><strong><center>'.mysql_error().'</center></strong></p><br>';
echo'</div></div>';
}
?>