File "process_payment.php"

Full Path: /home/ovanhxso/public_html/include/fonts/2612db/process_payment.php
File size: 4.18 KB
MIME-type: text/x-php
Charset: utf-8

<?php
// Connect to your database
//require_once 'config.php';

include 'panel/assets/constant/config.php';?>
<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
?>
<?php 

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Collect main form data
   $payment_id = $_POST['payment_id'] ?? null;
   //  $order_id = $_POST['order_id'] ?? null;
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone_number = $_POST['phone'];
$citizen = $_POST['citizen'];
     $amount = $_POST['amount'];
     $address = $_POST['address'];
     $state = $_POST['state'];
     $city = $_POST['city'];
     $pincode = $_POST['pin_code'];
     $pancard = $_POST['pan_card'];
     $remark = $_POST['remark'];
        $date=date('h:i:s');
    // Ensure the grand total is calculated and passed correctly

function generateRandomNumericID($length = 16) {
    $random_id = '';
    for ($i = 0; $i < $length; $i++) {
        $random_id .= rand(0, 9); // Append a random digit
    }
    return $random_id;
}

$random_id = generateRandomNumericID(16);

    // Prepare and insert into payments table
     $stmt = $conn->prepare("INSERT INTO join_member (name,citizen, email, phone,amount,address,state,city,pincode,pancard, payment_id,remark) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
    // $stmt->bindParam(':name', $name);
    // $stmt->bindParam(':email', $email);
    // $stmt->bindParam(':phone', $phone_number);
    //  $stmt->bindParam(':gender', $gender);
    // $stmt->bindParam(':amount', $amount);
    //  $stmt->bindParam(':address', $address);
    //   $stmt->bindParam(':state', $state);
    //   $stmt->bindParam(':city', $city);
    //   $stmt->bindParam(':pincode', $pincode);
    //   $stmt->bindParam(':pancard', $pancard);
       
    //  $stmt->bindParam(':payment_id', $payment_id);
    //  $stmt->bindParam(':order_id', $order_id);
     
       $stmt->execute([$name,$citizen,$email,$phone_number,$amount,$address,$state,$city,$pincode,$pancard,$payment_id,$remark]);
       
       $insertedId = $conn->lastInsertId();
       
   $stmt1 = $conn->prepare("SELECT * FROM emailsetting");
            $stmt1->execute();
            $result1 = $stmt1->fetchAll();
            print_r($result1);
            foreach ($result1 as $row) {

                $smtp_server = $row['smtp_server'];
                $smtp_password = $row['smtp_password'];
                $smtp_enc = $row['smtp_type'];
                $smtp_username = $row['smtp_username'];
                $smtp_port = $row['stmp_port'];
                $email = $row['email'];
                $email1=$row['email1'];
              
            }

            $dt = date('Y-m-d H:i:s');

            $msg1 = "Dear Admin, <br>
    You Have new message from <br> 
    Name: <strong>" . $_POST['name'] . "</strong>  <br>
    OVAID: <strong> $random_id </strong>  <br>
    email: <strong>" . $_POST['email'] . " </strong> <br>
  
    Phone: <strong>" . $_POST['phone'] . "</strong> <br>
     
   Amount: <strong>" . $_POST['amount'] . "</strong> <br>
   payment Id: <strong>" . $_POST['payment_id'] . "</strong> <br>
     ";

            $mail = new PHPMailer();
            $mail->Encoding = "base64";
            $mail->SMTPAuth = true;
            $mail->Host       = $smtp_server;
            $mail->Port       = $smtp_port;
            $mail->Username   = $smtp_username;
            $mail->Password   = $smtp_password;
            $mail->SMTPSecure = $smtp_enc;
            $mail->isSMTP();
            $mail->IsHTML(true);
            $mail->CharSet = "UTF-8";
            $mail->From = "noreply@ova.ngo";
         
            $mail->addAddress($email);
            $mail->addAddress($email1);
               
           
            $mail->Subject = 'Bharatiya Open Volunteer Association (OVA) ' . $dt;
            $mail->Body    = $msg1;
            $mail->AltBody = $msg1;

            $mail->send();
            // email end

          header("Location: receipt.php?payment_id=" . $payment_id);
          exit();
    }

?>