Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0750) : /home/celkcksm/jrslawcollege.com/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'php_mailer/Exception.php'; require 'php_mailer/PHPMailer.php'; require 'php_mailer/SMTP.php'; header('Content-Type: application/json'); // Set JSON response header if ($_SERVER["REQUEST_METHOD"] == "POST") { // Collect POST data $name = $_POST['name'] ?? ''; $dob = $_POST['dob'] ?? ''; $gender = $_POST['gender'] ?? ''; $parentName = $_POST['parentName'] ?? ''; $phone = $_POST['phone'] ?? ''; $email = $_POST['email'] ?? ''; $enquiryType = $_POST['enquiry-type'] ?? ''; $course = $_POST['course'] ?? ''; $address = $_POST['address'] ?? ''; $remarks = $_POST['remarks'] ?? 'N/A'; $llb_board = $_POST['llb_board'] ?? ''; $llb_percentage = $_POST['llb_percentage'] ?? ''; $ballb_board = $_POST['ballb_board'] ?? ''; $ballb_percentage = $_POST['ballb_percentage'] ?? ''; // Validate required fields if (!$name || !$dob || !$gender || !$parentName || !$phone || !$email || !$enquiryType || !$course || !$address) { http_response_code(400); echo json_encode(['status' => 'error', 'message' => 'All required fields must be filled.']); exit; } $mail = new PHPMailer(true); try { // Server settings $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'waytoadmissions21@gmail.com'; $mail->Password = 'lgle pkre mzzy sebw'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; $mail->Port = 465; // Sender and recipient $mail->setFrom('waytoadmissions21@gmail.com', 'Admission Portal'); $mail->addAddress('apurbakhanra09@gmail.com', 'Admissions Team'); // Email content $mail->isHTML(true); $mail->Subject = 'New Admission Form Submission'; $mail->Body = " <h2>Admission Form Details</h2> <p><strong>Student Name:</strong> {$name}</p> <p><strong>Date of Birth:</strong> {$dob}</p> <p><strong>Gender:</strong> {$gender}</p> <p><strong>Parent's Name:</strong> {$parentName}</p> <p><strong>Phone:</strong> {$phone}</p> <p><strong>Email:</strong> {$email}</p> <p><strong>Enquiry Type:</strong> {$enquiryType}</p> <p><strong>Course:</strong> {$course}</p> <p><strong>Address:</strong> {$address}</p> <p><strong>Remarks:</strong> {$remarks}</p> "; // Add course-specific fields if ($course === 'LLB' && ($llb_board || $llb_percentage)) { $mail->Body .= " <p><strong>University Name (Graduation):</strong> " . ($llb_board ?: 'N/A') . "</p> <p><strong>Percentage (Graduation):</strong> " . ($llb_percentage ?: 'N/A') . "</p> "; } elseif ($course === 'B.A. LL.B.' && ($ballb_board || $ballb_percentage)) { $mail->Body .= " <p><strong>Board Name (10 + 2):</strong> " . ($ballb_board ?: 'N/A') . "</p> <p><strong>Percentage (10 + 2):</strong> " . ($ballb_percentage ?: 'N/A') . "</p> "; } $mail->send(); echo json_encode(['status' => 'success', 'message' => 'Form submitted successfully. Mail sent.']); } catch (Exception $e) { http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo]); } } else { http_response_code(405); echo json_encode(['status' => 'error', 'message' => 'Invalid request method.']); } ?>