<?php
session_start();
include 'config.php';
?>
<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="Potenza - Job Application Form Wizard with Resume upload and Branch feature">
        <meta name="author" content="Ansonika">
        <title>Graduation - 2025</title>
        <link href="https://www.avit.ac.in/img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <!-- GOOGLE WEB FONT -->
        <link href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,600" rel="stylesheet">

        <!-- BASE CSS -->
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/menu.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/vendors.css" rel="stylesheet">

        <!-- YOUR CUSTOM CSS -->
        <link href="css/custom.css" rel="stylesheet">

       

    </head>
    <body style="background-color:#fff;" onLoad="setTimeout('delayedRedirect()', 100000)">
        <?php
        
        
        $name = insert_val($conn,$_POST['name']);
        $course = insert_val($conn,$_POST['course']);
        $batch = insert_val($conn,$_POST['batch']);
        $address = insert_val($conn,$_POST['address']);
        $status = insert_val($conn,$_POST['status']);
        $organization = insert_val($conn,$_POST['organization']);
        $self_desc=insert_val($conn,$_POST['self_desc']);
        $studies_course = insert_val($conn,$_POST['studies_course']);
        $insti_univ = insert_val($conn,$_POST['insti_univ']);
        $reg_no = insert_val($conn,$_POST['reg_no']);
        $parent_acc=insert_val($conn,$_POST['parent_acc']);
        $accompanying=insert_val($conn,$_POST['accompanying']);
        
        $mobile = insert_val($conn,$_POST['mobile']);
        $email = insert_val($conn,$_POST['email']);
        // $degree=insert_val($conn,$_POST['degree']);
        
      
       if(isset($_POST['utm_source'])){
            $utm_source =$_POST['utm_source'];
        }else if(isset($_GET['utm_source'])){
            $utm_source =$_GET['utm_source'];
        }else{
            $utm_source ='Website';
        }
        if(isset($_POST['utm_medium'])){
            $utm_medium =$_POST['utm_medium'];
        }else if(isset($_GET['utm_medium'])){
            $utm_medium =$_GET['utm_medium'];
        }else{
            $utm_medium ='Website';
        }
        if(isset($_POST['utm_campaign'])){
            $utm_campaign =$_POST['utm_campaign'];
        }else if(isset($_GET['utm_campaign'])){
            $utm_campaign =$_GET['utm_campaign'];
        }else{
            $utm_campaign ='Website';
        }
        $added = time();
	    if((isset($name) && !empty($name)) && (isset($course) && !empty($course)) && (isset($batch) && !empty($batch)) && (isset($status) && !empty($status)) && (isset($mobile) && !empty($mobile)) && (isset($email) && !empty($email)) && (isset($reg_no) && !empty($reg_no)) && (isset($parent_acc) && !empty($parent_acc))){
            $sql = "INSERT INTO graduation2025 SET name='".$name."', course='".$course."',batch='".$batch."',mobile='".$mobile."',email='".$email."', address='".$address."', present_status='".$status."',emp_organization='".$organization."', self_desc='".$self_desc."', higher_insti_univ='".$insti_univ."', higher_course='".$studies_course."', reg_no='".$reg_no."',parent_acc='".$parent_acc."',accompanying='".$accompanying."',cdate='".$regon."'";
            $result=mysqli_query($conn, $sql);
	    }else{
	        echo "<script type='text/javascript'>
                alert('Mandatory field is missing,Please check all mandatory fields. Thank you.');
                window.location.href='index.php';
            </script>";
	    }
	    //window.location.href='index.php';
           if ($result) {
			$last_id = mysqli_insert_id($conn);
          	//$last_id = sprintf('%0d',$last_id);
              //Email Function
            $siteUrl="https://avcampusadmissions.com/event/2025/graduation2025/img/avit-newlogo.png";
            $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="format-detection" content="date=no" /><meta name="format-detection" content="address=no" /><meta name="format-detection" content="telephone=no" /><meta name="x-apple-disable-message-reformatting" /><link href="https://fonts.googleapis.com/css?family=Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet"/><style type="text/css" media="screen">body{padding:0 !important;margin:0 !important;display:block !important;min-width:100% !important;width:100% !important;background:#fff;-webkit-text-size-adjust:none}a{color:#66b7f0;text-decoration:none}p{padding:0 !important;margin:0 !important}img{-ms-interpolation-mode:bicubic}.mcnPreviewText{display:none !important}@media only screen and (max-device-width: 480px), only screen and (max-width: 480px){.mobile-shell{width:100% !important;min-width:100% !important}.m-center{text-align:center !important}.center{margin:0 auto !important}.td{width:100% !important;min-width:100% !important}.m-br-3{height:3px !important}.m-br-4{height:4px !important;background:#ffffff !important}.m-br-15{height:15px !important}.m-br-25{height:25px !important}.m-td,.m-hide{display:none !important;width:0 !important;height:0 !important;font-size:0 !important;line-height:0 !important;min-height:0 !important}.m-block{display:block !important}.fluid-img img{width:100% !important;max-width:100% !important;height:auto !important}.column-top,.column{float:left !important;width:100% !important;display:block !important}.content-spacing{width:15px !important}.m-bg{display:block !important;width:100% !important;height:auto !important;background-position:center center !important}.h-auto{height:auto !important}.plr-15{padding-left:15px !important;padding-right:15px !important}.w-2{width:2% !important}.w-49{width:49% !important}.pb-4{padding-bottom:4px !important}.pb-15{padding-bottom:15px !important}.pt-0{padding-top:0 !important}.h1,.h1-white{font-size:36px !important;line-height:46px !important}.h2{font-size:26px !important;line-height:36px !important}.text-btn-large,.text-btn-large-white{padding:15px 25px !important}.text-btn,.text-btn-1,.text-btn-1-white{padding:12px 15px !important}}</style></head><body class="body" style="padding:0 !important; margin:0 !important; display:block !important; min-width:100% !important; width:100% !important; background:#ffffff; -webkit-text-size-adjust:none;"><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff"><tr><td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="top"><table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell"><tr><td class="plr-15" style="padding: 20px 0;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><th class="column-top" valign="top" width="360" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal; vertical-align:top;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="text-top to-left m-center" style="color:#888888; font-size:12px; line-height:20px; text-align:left;"> </td></tr></table></th><th class="column-top" valign="top" width="15" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal; vertical-align:top;"><div style="font-size:0pt; line-height:0pt;" class="m-br-15"></div></th><th class="column-top" valign="top" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal; vertical-align:top;"><table width="100%" border="0" cellspacing="0" cellpadding="0"></table></th></tr></table></td></tr></table></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td> <repeater> <layout label="Section - Intro"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="img" height="245" bgcolor="#fff" style="font-size:0pt; line-height:0pt; text-align:left;">&nbsp;</td></tr></table></td><td align="center" valign="top" width="650" class="mobile-shell"><table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell"><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="plr-15" style="padding: 0px;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="h1 fw-medium" style="padding-bottom: 20px; color:#4a4a4a; font-size:40px; line-height:50px; text-align:center; font-weight:500;"></td></tr><tr><td class="text-1" style="padding-bottom: 30px; color:#4a4a4a; font-size:16px; line-height:30px; text-align:justify;"> <multiline><a alt="AVIT" href="'.$siteUrl.'"><img src="'. $logoUrl .'" style="width:36%;height:36%;"></a><br/>
             Dear  '.$name.' ,</br><p>&nbsp;</p> <b>Greetings from Aarupadai Veedu Institute of Technology!!!</b> </p>
             <p>"Thank you for registering for Graduation Day 2025—congratulations on your achievement; it deserves a grand celebration!"</p>
			   </multiline></td></tr><tr><td class="text-2" style="color:#4a4a4a; font-size:11px; line-height:15px; text-align:center;"></td></tr></table></td></tr></table></td></tr></table></td><td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="img" height="20" bgcolor="#ffffff" style="font-size:0pt; line-height:0pt; text-align:left;">&nbsp;</td></tr></table></td></tr></table> </layout> <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="top"><table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell"><tr><td class="plr-15" style="padding: 0;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><th class="column-top" valign="top" width="225" style="font-size:9pt; line-height:15pt; padding:0; margin:0; font-weight:normal;text-align:left; vertical-align:top;"><multiline> <span class="link-4" style="color:#000; text-decoration:none;">Best Wishes<br/><b style="color:#000;font-size:14px;">Authorised signatory</b> <br/>Aarupadai Veedu Institute of Technology<br/>Vinayaka missions Research Foundation<br /> <br />Vinayaka Nagar,<br /> Rajiv Gandhi Salai, <br />(Old Mahabalipuram Road) Paiyanoor,<br /> Chennai- 603 104,<br />Tamil Nadu, India</multiline></th><th class="column-top" valign="top" width="15" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal; vertical-align:top;"><div style="font-size:16px; line-height:30px;" class="m-br-15"></div></th><th class="column-top" valign="top" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal; vertical-align:top;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="right" style="padding: 10px 0 25px 0;"><table border="0" cellspacing="0" cellpadding="0" class="center">
			   <tr>
			   </tr>
			   </table></td></tr><tr><td class="text-footer-1 to-right m-center" align="right" style="color:#a0a09a; font-size:11px; line-height:22px; text-align:right;"> <div class="img-center" style="font-size:0pt; line-height:0pt; text-align:right;"><a href="https://avit.ac.in" target="_blank"><img src="https://www.avit.ac.in/online-scholarship-test-2021/images/logo.png" border="0"  editable="true" alt="" style="width: 200px;height:auto;" /></a></div></td></tr></table></th></tr></table></td></tr></table></td></tr></table><br /><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#f4f4f4"><tr><td align="center" valign="top"><table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell"><tr><td class="text-bottom" style="padding: 35px 15px; color:#888888; font-size:11px; line-height:18px; text-align:center;"> For any queries kindly contact (0)8754541022 - 26. Write your feedback to us on graduationday@avit.ac.in <br /> Should you wish to cancel your subscription, please <unsubscribe class="link-3-u" style="color:#a8a8a8; text-decoration:underline;"><span class="link-3-u" style="color:#a8a8a8; text-decoration:underline;">click here to unsubscribe.</span></unsubscribe></td></tr></table></td></tr></table></td></tr></table></body></html>';
            require 'sendgrid-php/vendor/autoload.php';
            $sendgrid = new \SendGrid\Mail\Mail();
            $sendgrid->setFrom("admissions@vinayakamissions.com", "22nd GRADUATION DAY - 2025");
            $sendgrid->setSubject("22nd GRADUATION DAY - 2025");
            $sendgrid->addCc("graduationday@avit.ac.in");
            //$sendgrid->addCc("gm.digitalmarketing@vinayakamissions.com");
            $sendgrid->addCc("sugunavel@vinayakamissions.com");
            $sendgrid->addTo("$email", "$name");
            $sendgrid->addContent("text/html", $body);
            $sendgridkey = new \SendGrid('SG.cX6yJdbeTY6SVtjySIe_YA.xySHk3hwdSky-LjTVVc8s_YsASwSkKKEce3hT3QvDqw');
            try {
                $response = $sendgridkey->send($sendgrid);
                if($response){
                ?>
                
                <?php
               header("refresh:2;url=success.php?lastid=" . urlencode($last_id) . "&regno=" . urlencode($reg_no) . "&name=" . urlencode($name));

                exit;

                }else{
                    
                }
            } catch (Exception $e) {
                echo 'Caught exception: ' . $e->getMessage() . "\n";
            }
             
        }
        ?>
		
    </body>
</html>