D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
balhit1357
/
balhit.ac.in
/
OldSite
/
Filename :
online_reg_mail.php
back
Copy
<?php require('recaptcha-master_new/src/autoload.php'); $email=$_POST["email"]; // configure // an email address that will be in the From field of the email. $from = 'info@gradientsoftech.com'; // an email address that will receive the email with the output of the form $sendTo = 'bbvadmission@gmail.com'; // subject of the email $subject = 'New Student Registration Request'; // form field names and their translations. // array variable name => Text to appear in the email $fields = array('std_f_name' => 'Student First Name', 'std_l_name' => 'Student Last Name', 'uid_num' => 'Aadhaar Card Number', 'd_o_b' => 'Date of Birth', 'age_yr' => 'Age (Year)', 'age_mon' => 'Age (Month)', 'class' => 'Class', 'gender' => 'Gender', 'f_name' => 'Father Name', 'f_quli' => 'Father Qualification', 'f_occu' => 'Father Occupation', 'f_mob_no' => 'Father Mob no', 'm_name' => 'Mother Name', 'm_quli' => 'Mother Qualification', 'm_occu' => 'Mother Occupation', 'm_mob_no' => 'Mother Mob no', 'hostel' => 'Hostel Accomodation', 'e_mail' => 'E-mail Address', 'city_name' => 'City Name', 'add_ress' => 'Address', 'pre_sch_nm' => 'Pervious School Name', 'medium' => 'Medium', 'board' => 'Board'); // message that will be displayed when everything is OK :) $okMessage = 'Thank you for your enquiry. We will Contact you shortly.'; // If something goes wrong, we will display this message. $errorMessage = 'There was an error while submitting the form. Please try again later'; // ReCaptch Secret $recaptchaSecret = '6Led0qsUAAAAAHAxEQj-6aS41WNOU5eDSv0dj8M9'; // let's do the sending // if you are not debugging and don't need error reporting, turn this off by error_reporting(0); error_reporting(E_ALL & ~E_NOTICE); try { if (!empty($_POST)) { // validate the ReCaptcha, if something is wrong, we throw an Exception, // i.e. code stops executing and goes to catch() block /* if (!isset($_POST['g-recaptcha-response'])) { throw new \Exception('ReCaptcha is not set.'); } // do not forget to enter your secret key from https://www.google.com/recaptcha/admin $recaptcha = new \ReCaptcha\ReCaptcha($recaptchaSecret, new \ReCaptcha\RequestMethod\CurlPost()); // we validate the ReCaptcha field together with the user's IP address $response = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); if (!$response->isSuccess()) { throw new \Exception('ReCaptcha was not validated.'); } */ // everything went well, we can compose the message, as usually $emailText = "You have a new message from your contact form\n=============================\n"; foreach ($_POST as $key => $value) { // If the field exists in the $fields array, include it in the email if (isset($fields[$key])) { $emailText .= "$fields[$key]: $value\n"; } } // All the neccessary headers for the email. $headers = array('Content-Type: text/plain; charset="UTF-8";', 'From: ' . $from, 'Reply-To: ' . $from, 'Return-Path: ' . $from, ); // Send email mail($sendTo, $subject, $emailText, implode("\n", $headers)); $responseArray = array('type' => 'success', 'message' => $okMessage); } } catch (\Exception $e) { $responseArray = array('type' => 'danger', 'message' => $e->getMessage()); } if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $encoded = json_encode($responseArray); header('Content-Type: application/json'); echo $encoded; } else { echo $responseArray['message']; } ?> <script> alert('Success'); window.location.href="index_1.php"; </script> '