This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit.php
148 lines (128 loc) · 4.87 KB
/
submit.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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Latest compiled and minified CSS -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<title>Online Registration</title>
<style>
p, h1 {
text-align: center;
}
</style>
</head>
<body>
<div class = "container">
<?php
/* validation
$name = $email = $gender = $comment = $website = "";
$nameval=$emailval=$contactval=$rollnoval=$deptval=$collegeval"";
if(empty($name))
$nameval="Empty field";
else if(!preg_match("/^[a-zA-Z ]{4,}$/",$name))
$nameval="ImproperName";
if(empty($email))
$emailval="Empty Field";
if(empty($contact))
$phoneval="Empty Field";
if(empty($rollno))
$rollnoval="Empty Field";
else if(!preg_match("/^[0-9]{10}$/",$contact))
$contactval="Enter 10-digit no.";
if(empty($dept))
$deptval="Empty Address";
if(!preg_match("/^[a-zA-z][A-Za-z0-9]*@[A-Za-z]+\.[a-zA-Z]{2,3}/",$email))
$emailval="Invalid email";
if(!preg_match("/^[0-9]{2}[A-Za-z][0-9]{2}[A-Za-z][0-9]{4}$/",$rollno))
$rollnoval="Invalid roll no";
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
*/
$name = $_POST["name"];
$email = $_POST["email"];
$contact = $_POST["contact"];
$rollno = $_POST["roll"];
$dept = $_POST["dept"];
$college = $_POST["institution"];
if($dept == "Other")
$dept = $_POST["dept-other"];
// using files
$fp = fopen("eventdata.txt", "r");
$filename = fgets($fp);
$filename = substr($filename, 0, -1);
fclose($fp);
substr($filename, 0, -2);
$fcount = fopen("regcount.txt", "r");
fscanf($fcount, "%d", $count);
fclose($fcount);
$count = $count + 1;
$fcount = fopen("regcount.txt", "w");
fwrite($fcount, $count);
fclose($fcount);
$fp = fopen($filename." participants.csv", "a");
fwrite($fp, $count . "," . $name . "," . $email . "," . $rollno . "," . $contact . "," . $dept . "\n");
fclose($fp);
// using database
/*
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'root';
$dbdata='user';
$conn = mysql_connect($dbhost, $dbuser, $dbpass,$dbdata);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = "INSERT INTO user ".
"(name,email,contact,college,rollno,department) ".
"VALUES ".
"('$name','$email','$contact','$college','$rollno','$dept')";
mysql_select_db('user');
$retval = $conn->mysql_query( $sql);
$result = mysql_query("SELECT * FROM user", $conn);
echo $result->num_rows;
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$getemail=$row["email"];
if(!strcmp($getmail,$email)){
echo "email already entered";
}
}
echo "Entered data successfully\n";
mysql_close($conn);
}*/
?>
<br>
<p>You are successfully registered as</p>
<h1><?php echo $count ?></h1>
</div>
</body>
</html>