-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
137 lines (126 loc) · 3.79 KB
/
admin.php
File metadata and controls
137 lines (126 loc) · 3.79 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Bootstrap -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- FontAwesome -->
<link rel="stylesheet" href="css/font-awesome.min.css">
<!-- Animation -->
<link rel="stylesheet" href="css/animate.css">
<title>Download Data</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/style.css">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
<?php
if (!empty($_POST)) {
include('settings.php');
$google_resp = array_pop($_POST);
if (!empty($google_resp) && $_POST[pass_wd] == 'asioe') {
include('settings.php');
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//echo $_GET[paymentid];
$query = "SELECT * FROM reg_form";
//echo $query;
$sqlsearch = mysqli_query($conn, $query);
if ($sqlsearch->num_rows == 0) {
echo "No Data Found.";
} else {
$headers = $sqlsearch->fetch_fields();
foreach ($headers as $header) {
$head[] = $header->name;
}
$fp = fopen('php://output', 'w');
/*foreach ($row as $val) {
fputcsv($fp, $val);
}*/
if ($fp && $sqlsearch) {
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="export.csv"');
header('Pragma: no-cache');
header('Expires: 0');
fputcsv($fp, array_values($head));
while ($row = $sqlsearch->fetch_array(MYSQLI_NUM)) {
fputcsv($fp, array_values($row));
}
die;
}
fclose($fp);
?>
<div class="table-responsive" id="employee_table">
<table class="table table-bordered">
<tr>
<?php foreach ($headers as $header) {
echo "<th>" . $header->name . "</th>";
} ?>
</tr>
<?php
while ($row = mysqli_fetch_array($sqlsearch)) {
?>
<tr>
<td><?php echo $row["id"]; ?></td>
<td><?php echo $row["firstname"]; ?></td>
<td><?php echo $row["lastname"]; ?></td>
<td><?php echo $row["email"]; ?></td>
<td><?php echo $row["phone"]; ?></td>
<td><?php echo $row["address"]; ?></td>
<td><?php echo $row["college"]; ?></td>
<td><?php echo $row["branch"]; ?></td>
<td><?php echo $row["city"]; ?></td>
<td><?php echo $row["year"]; ?></td>
<td><?php echo $row["aadhar"]; ?></td>
<td><?php echo $row["paymentid"]; ?></td>
<td><?php echo $row["source"]; ?></td>
<td><?php echo $row["reg_date"]; ?></td>
</tr>
<?php
}
?>
</table>
</div>
<?php
}
$conn->close();
} else {
echo "Something Went wrong!";
}
} else {
?>
<section id="section-registration" class="section-padding">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 text-center wow fadeInUp">
<div class="section-heading">
<h2 class="heading-title">Get Data</h2>
</div>
</div>
</div>
<div class="row">
<div class="registration-form">
<form class="registration-box" method="post" action="admin.php">
<div class="col-md-6 col-sm-6 ">
<div class="form-group">
<label>Padword*</label>
<input id="form_password" type="password" name="pass_wd" class="form-control">
</div>
<div class="g-recaptcha" data-sitekey="6LdWrBgUAAAAADSarYajOQsMjXeNT0EsQBSGW56c"></div>
<div class="form-group">
<input type="submit" class="btn btn-success btn-send" value="Get Data">
</div>
</div>
</form>
</div>
</div>
</section>
<?php
}
?>
</body>
</html>