forked from prameshbajra/BVC-Student-Portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemailnew.php
143 lines (119 loc) · 6.04 KB
/
emailnew.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
<!-- Developed by Saurav Bajracharya and Pramesh Bajracharya -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="shortcut icon" href="bvc.png" type="image/x-icon" />
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="animate.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" language="javascript">
function checkedbox(element) {
var checkboxes = document.getElementsByTagName('input');
if (element.checked) {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = true;
}
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
console.log(i)
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
}
</script>
<script src="js/tinymce/js/tinymce/tinymce.min.js"></script>
<script>
tinymce.init({
selector: 'textarea'
});
</script>
</head>
<div class="clear"></div>
<div class="centralDiv" style="margin-left:5%;">
<?php
include('includes/config.php');
if(isset($_POST['check']) == true)
{
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
$from = '[email protected]';
$reply = '[email protected]';
foreach($_POST['check'] as $key => $value)
{
// Set content-type for sending HTML email
$headers = "BVC Engineering College" . "\r\n";
$headers .= "Odalarevu, Amalapuram" . "\r\n";
$headers .= "From: <".$from.">\r\n";
$headers .= "Reply-To: ".$reply."";
if(@mail($value,$subject,$message,$headers))
{
echo '<div class="container-fluid" style="width:130%;">
<div class="alert alert-success fade in">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>';
echo '<strong>Success! </strong>';
echo ' Mail has been Successfully sent to '.$value.'</br>';
echo '</div></div>';
}
}
}
?>
<div class="container-fluid" style="width:130%;">
<center>
<p>
<h2>Please Select Students</h2>
</p><br><br>
<form method="post" action="">
<?php
// Retrieve Email from Database
$getemail = mysql_query("SELECT * FROM profiles");
if (!$getemail) die('MySQL Error: ' . mysql_error());
echo '<table class="table table-bordered">';
echo "<thead>
<tr>
<th><input type='checkbox' onchange='checkedbox(this)' name='chk'/><h4> All</h4></th>
<th><h4>Registration Number</h4></th>
<th><h4>Student's Name</h4></th>
<th><h4>E-mail</h4></th>
</tr>
</thead>";
if (mysql_num_rows($getemail) == 0) {
echo "<tbody><tr><td colspan='3'>No Data Avaialble</td></tr></tbody>";
}
while ($row = mysql_fetch_assoc($getemail)) {
echo "<tbody><tr><td><input value='".$row['email']."' type='checkbox' name='check[]'/></td>";
echo "<td >".$row['roll_no']."</td>";
echo "<td >".$row['name']."</td>";
echo "<td >".$row['email']."</td></tr></tbody>";
}
echo "</table>";
?>
<br><br>
<p>Email Subject: <input type="text" name="subject" value="" class="form-control" /></p>
<br><br>
<p>Email Content: <textarea name="message" cols="40" rows="6"></textarea></p>
<center><input type='submit' name='submit' value='Send Email Now' class="btn btn-primary btn-block" />
</center>
<br></form>
</div>
</div>
</div>
</center>
</div>
<footer id="footer">
<h4 id="left">Copyright © - <?php echo "20".date('y');?></h4>
<h4 id="right">BVCEC</h4>
</footer>
</body>
</html>