-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveresult.php
77 lines (69 loc) · 2.49 KB
/
saveresult.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
<?php
function filenotopened()
{
mail("[email protected]","Opinion Poll Pain","File not opening!");
return "Some problem has occurred.<br>Necessary action has been taken.<br>Please come back again after sometime.";
}
$cr = $_POST['cr'];
$sports = $_POST['sports'];
$alumni = $_POST['alumni'];
$social = $_POST['social'];
$name = $_POST['naam'];
$name = trim($name);
$name = htmlspecialchars($name);
$file = fopen("pollcount.csv",'r') or exit(filenotopened());
$line = fgetcsv($file);
$line = fgetcsv($file);
fclose($file);
$names = array
(
"Dibyendu","Utkarsh","CRNone","Rahul","Kunal",
"Harsha","SportsNone","Sivaprasad","Shudhatma",
"Nirish","Akhil","SocialNone","Rawal","Devanshu",
"Rathi","Yadav","Priyanshu","AlumniNone"
);
if(empty($name)) {$name = "Anonymous";}
if(empty($cr)) {$cr = "crnone";}
if(empty($sports)) {$sports = "sportsnone";}
if(empty($social)) {$social = "socialnone";}
if(empty($alumni)) {$alumni = "alumninone";}
if($cr == "dibyendu") {$cr = "Dibyendu Mondal";$line[0]++;}
elseif($cr == "utkarsh") {$cr = "Utkarsh Kumar";$line[1]++;}
elseif($cr == "crnone") {$cr = "None";$line[2]++;}
if($sports == "rahul") {$sports = "Rahul Lingala";$line[3]++;}
elseif($sports == "kunal") {$sports = "Kunal Agrawal";$line[4]++;}
elseif($sports == "harsha") {$sports = "Venkat Harsha";$line[5]++;}
elseif($sports == "sportsnone") {$sports = "None";$line[6]++;}
if($social == "siva") {$social = "Sivaprasad S";$line[7]++;}
elseif($social == "shudh") {$social = "Shudhatma Jain";$line[8]++;}
elseif($social == "nirish") {$social = "Sai Nirish Padala";$line[9]++;}
elseif($social == "akhil") {$social = "Akhil Thatimpula";$line[10]++;}
elseif($social == "socialnone") {$social = "None";$line[11]++;}
if($alumni == "rawal") {$alumni = "Rawal Khirodkar";$line[12]++;}
elseif($alumni == "devanshu") {$alumni = "Devanshu Koyalkar";$line[13]++;}
elseif($alumni == "rathi") {$alumni = "Aashish Rathi";$line[14]++;}
elseif($alumni == "yadav") {$alumni = "Shubham Yadav";$line[15]++;}
elseif($alumni == "priyanshu") {$alumni = "Priyanshu Gupta";$line[16]++;}
elseif($alumni == "alumninone") {$alumni = "None";$line[17]++;}
$out = $name.",".$cr.",".$sports.",".$social.",".$alumni."\n";
echo $out,"<br>";
$file = fopen("polls.txt",'a+');
fwrite($file,$out);
fclose($file);
$var = "";
$file = fopen("pollcount.csv",'w');
foreach ($names as $elm)
{
$var = $var.$elm.",";
}
$var = chop($var,",");
$var = $var."\n";
foreach ($line as $elm)
{
$var = $var.$elm.",";
}
$var = chop($var,",");
$var = $var."\n";
fwrite($file,$var);
fclose($file);
?>