forked from kondjaMikaelson/College_Portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresp.php
47 lines (42 loc) · 1.02 KB
/
resp.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
<?php session_start();
if(!isset($_SESSION['username']))
{
echo"hello";
header("Location:unaval.php");
exit();
}
if(!isset($_POST))
{
header("Location:unaval.php");
exit();
}
$sub=$_POST["subject"];
$id=$_SESSION['username'];
$teach=$_POST['teacher'];
$subject ="Mail Function in PHP";
$from="[email protected]";
$message ="Request for extra lecture for $sub by $id";
$headers = "From:".$from;
$servername = "localhost";
$username = "root";
$passwordPHP = "";
$dbname="timetable";
$conn = new mysqli($servername,$username,$passwordPHP,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql="select EmailId from stud_teachers where Name='".$teach."'";
$result=$conn->query($sql);
$email="";
if (isset($result->num_rows)&& $result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$email=$row['EmailId'];
break;
}
}
$res=mail($email,$subject,$message,$headers);
header("Location:success.php");
exit();
?>