Viewing file: save_attendance.php (6.85 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require 'connection.php';
include 'sendgrid_mail.php';
// echo $name=$_REQUEST['uname'];
// echo $course=$_REQUEST['course'];
// echo $email="ajeeshmnmd@gmail.com";
// echo $date=$_REQUEST['date'];
// echo $comments=$_REQUEST['comments'];
// echo $staff=$_REQUEST['staff'];
// echo $student_id=$_REQUEST['student_id'];
// die();
$name=$_REQUEST['uname'];
$course=$_REQUEST['course'];
$email="campusadmin@srishtis.com";
$student_email=$_REQUEST['student_email'];
$staff_email=$_REQUEST['staff_email'];
//$email1="ajeesh.gopi@srishtis.com";
//$email="ajeeshmnmd@gmail.com";
$date=$_REQUEST['date'];
$comments=$_REQUEST['comments'];
$staff=$_REQUEST['staff'];
$student_id=$_REQUEST['student_id'];
//echo "insert into student_attendance(student_id,student_name,course,staff,date,comments) values('$student_id','$name','$course','$staff','$date','$comments')";
//echo"SELECT * FROM student_attendance where student_id='$student_id',student_name='$name',course='$course',staff='$staff',date='$date'";
$sql1="SELECT * FROM student_attendance where student_id='$student_id' and student_name='$name' and course='$course' and staff='$staff' and date='$date'";
$result1= $con->query($sql1);
$count1=$con->affected_rows;
$count1;
if($count1>0)
{
echo "Already Exist";
}
else
{
$sql="insert into student_attendance(student_id,student_name,course,staff,date,comments) values('$student_id','$name','$course','$staff','$date','$comments')";
$result= $con->query($sql);
$count=$con->affected_rows;
//mailto:campusadmin@srishtis.com
//$to ="srishticampusteam@srishtis.com";
$to ="ajeeshmnmd@gmail.com";
$subject="Srishti Campus Team";
$output = "<div style='font-size:15px;border-style: outset;'><table style='margin-left:20px;'><tr><td><caption><h4>Attendance Submitted</h4></caption></td></tr><tr><td>Name:</td><td>".$name."</td></tr><tr><td>Course:</td><td>".$course."</td></tr><tr><td>Date:</td><td>".$date."</td></tr><tr><td>Staff:</td><td>".$staff."</td></tr><tr><td>Comments:</td><td>".$comments."</td></tr></table></div></br>";
$to_1 =$email;
$to_11 =$staff_email;
$to_12 =$student_email;
//$to_11 =$email1;
$from_1='campusadmin@srishtis.com';
// $subject_1="Srishti Campus Team";
$subject_1=$name." | ".$staff." | ".$course." | ".$date;
$headers_1 = 'MIME-Version: 1.0' . "\n";
$headers_1 .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers_1 .= "From: Srishti <campusadmin@srishtis.com>" .
"Reply-To: campusadmin@srishtis.com\n".
"X-Mailer: php/". phpversion();
$output_1="Thank you for contacting Srishti-Quality Beyond Contract. We will get in touch with you as soon as we process your Query!!";
// create new sendgrid mail
$email_sg = new \SendGrid\Mail\Mail();
// specify the email/name of where the email is coming from
$email_sg->setFrom( FROM_EMAIL, FROM_NAME );
// set the email subject line
$email_sg->setSubject( $subject_1 );
// specify the email/name we are sending the email to
$email_sg->addTo( $to_1, $to_1 );
///
// $email_addresses = [
// 'campusadmin@srishtis.com',
// 'ajeeshmnmd@gmail.com',
// 'ajeesh.gopi@srishtis.com'
// ];
// foreach ( $email_addresses as $email_address ) {
// $personalization = new Personalization();
// $personalization->addTo( new To( $email_address ) );
// $email_sg->addPersonalization( $personalization );
// }
/////
//$email_sg->addTo( $to_1,$to );
// add our email body content
$email_sg->addContent("text/html", $output);
// create new sendgrid
$sendgrid = new \SendGrid( SENDGRID_API_KEY );
try {
// try and send the email
$response = $sendgrid->send( $email_sg );
echo "1";
} catch ( Exception $e ) {
// something went wrong so display the error message
echo 'Caught exception: '. $e->getMessage() ."\n";
}
/////
// create new sendgrid mail
$email_sg1 = new \SendGrid\Mail\Mail();
// specify the email/name of where the email is coming from
$email_sg1->setFrom( FROM_EMAIL, FROM_NAME );
// set the email subject line
$email_sg1->setSubject( $subject_1 );
// specify the email/name we are sending the email to
$email_sg1->addTo( $to_11, $to_11 );
///
// $email_addresses = [
// 'campusadmin@srishtis.com',
// 'ajeeshmnmd@gmail.com',
// 'ajeesh.gopi@srishtis.com'
// ];
// foreach ( $email_addresses as $email_address ) {
// $personalization = new Personalization();
// $personalization->addTo( new To( $email_address ) );
// $email_sg->addPersonalization( $personalization );
// }
/////
//$email_sg->addTo( $to_1,$to );
// add our email body content
$email_sg1->addContent("text/html", $output);
// create new sendgrid
$sendgrid1 = new \SendGrid( SENDGRID_API_KEY );
try {
// try and send the email
$response1 = $sendgrid1->send( $email_sg1 );
//echo "1";
} catch ( Exception $e ) {
// something went wrong so display the error message
echo 'Caught exception: '. $e->getMessage() ."\n";
}
/////
/////
// create new sendgrid mail
$email_sg2 = new \SendGrid\Mail\Mail();
// specify the email/name of where the email is coming from
$email_sg2->setFrom( FROM_EMAIL, FROM_NAME );
// set the email subject line
$email_sg2->setSubject( $subject_1 );
// specify the email/name we are sending the email to
$email_sg2->addTo( $to_12, $to_12 );
///
// $email_addresses = [
// 'campusadmin@srishtis.com',
// 'ajeeshmnmd@gmail.com',
// 'ajeesh.gopi@srishtis.com'
// ];
// foreach ( $email_addresses as $email_address ) {
// $personalization = new Personalization();
// $personalization->addTo( new To( $email_address ) );
// $email_sg->addPersonalization( $personalization );
// }
/////
//$email_sg->addTo( $to_1,$to );
// add our email body content
$email_sg2->addContent("text/html", $output);
// create new sendgrid
$sendgrid2 = new \SendGrid( SENDGRID_API_KEY );
try {
// try and send the email
$response2 = $sendgrid2->send( $email_sg2 );
//echo "1";
} catch ( Exception $e ) {
// something went wrong so display the error message
echo 'Caught exception: '. $e->getMessage() ."\n";
}
/////
}
?>
|