Some Data is losing after making the payment in php myadmin why?

I have created a html application form in which I have integrated razor payment gateway after the user pays it will send a mail that application recieved. My issue is out of 12 , 2 or 3 datas are missing in the database and also they didn’t recieved any mail . I hosted this in vps server contabo how to resolve from this ?

<?php

session_start();



$servername = "173.212.211";

$username = "root";

$password = "";

$database = "contactsams";



$errors = [];



$conn = new mysqli($servername, $username, $password, $database);

try {

    if ($conn->connect_error) {

        throw new Exception("Connection failed: " . $conn->connect_error);

    }

} catch (Exception $e) {

    $errors[] = $e->getMessage();

}

function generateApplicationID($conn)

{

    $currentYear = date("Y");

    $result = $conn->query("SELECT COUNT(*) AS count FROM admissions");

    $row = $result->fetch_assoc();

    $count = $row["count"] + 1001;

    $applicationID = "SAMS-" . $count . "-" . $currentYear;



    return $applicationID;

}



require "./vendor/phpmailer/phpmailer/src/Exception.php";

require "./vendor/phpmailer/phpmailer/src/PHPMailer.php";

require "./vendor/phpmailer/phpmailer/src/SMTP.php";



use PHPMailerPHPMailerPHPMailer;

use PHPMailerPHPMailerException;



$autoloadPath = __DIR__ . "/vendor/autoload.php";



if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $firstName = mysqli_real_escape_string($conn, $_POST["first_name"]);

    $lastName = mysqli_real_escape_string($conn, $_POST["last_name"]);

    $phoneNumber = mysqli_real_escape_string($conn, $_POST["phone_number"]);

    $dob = mysqli_real_escape_string($conn, $_POST["dob"]);

    $email = mysqli_real_escape_string($conn, $_POST["email"]);

    $fatherName = mysqli_real_escape_string($conn, $_POST["father_name"]);

    $motherName = mysqli_real_escape_string($conn, $_POST["mother_name"]);

    $parentPhoneNumber = mysqli_real_escape_string(

        $conn,

        $_POST["parent_phone_number"]

    );

    $selectedCourse = mysqli_real_escape_string($conn, $_POST["course"]);

    $selectedCourseList = mysqli_real_escape_string(

        $conn,

        $_POST["course_list"]

    );

    $highestQualification = mysqli_real_escape_string(

        $conn,

        $_POST["highest_qualification"]

    );



    if (empty($fatherName)) {

        $errors[] = "All fields are required.";

    }



    if (empty($errors)) {

        try {

            $applicationID = generateApplicationID($conn);

            $sql = "INSERT INTO admissions (application_id, first_name, last_name, phone_number, dob, email, father_name, mother_name, parent_phone_number, selected_course, selected_course_list, highest_qualification)

            VALUES ('$applicationID', '$firstName', '$lastName', '$phoneNumber', '$dob', '$email', '$fatherName', '$motherName', '$parentPhoneNumber', '$selectedCourse', '$selectedCourseList', '$highestQualification')";



            if ($conn->query($sql) === true) {

                $mail = new PHPMailer(true);



                try {

                    $mail->isSMTP();

                    $mail->Host = "smtp.gmail.com";

                    $mail->SMTPAuth = true;

                    $mail->Username = "[email protected]";

                    $mail->Password = "oaknqyyadwpkkmal";

                    $mail->SMTPSecure = "ssl";

                    $mail->Port = 465;

                    $htmlContent =

                        '

                    <!DOCTYPE html>

                    <html lang="en">

                    

                    <head>

                        <meta charset="UTF-8">

                        <meta name="viewport" content="width=device-width, initial-scale=1.0">

                        <title>Email</title>

                    </head>

                    

                    <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: white;">

                        <div style="background-color: #27538c; padding: 20px; text-align: center;">

                            <p style="font-size: 14px; color: #ffffff;">WE HAVE RECEIVED YOUR APPLICATION FORM! THANK YOU!</p>

                        </div>

                        <div style="margin-top: 20px; text-align: center;">

                            <img src="https://i.ibb.co/1fGCtnH/image-1.png" alt="img" style="display: block; margin: 0 auto;">

                            <p style="font-size: 28px; font-weight: bold; margin-top: 20px;">Thank you</p>

                            <p style="font-size: 28px; font-weight: bold;">For Choosing SAMS</p>

                        </div>

                        <div style="margin: 20px 0 40px 0; padding: 20px; background-color: #ffffff;">

                            <p style="font-size: 16px; margin-bottom: 10px;">Dear Prospective Student,</p>

                            <p style="font-size: 16px; margin-bottom: 10px;">Thanks for choosing SAMS .</p>

                            <p style="font-size: 16px; margin-bottom: 10px;">Your Application ID: [' .

                        $applicationID .

                        ']</p>

                            <p style="font-size: 16px; margin-bottom: 10px;">Kindly use the above ID for further process.</p>

                            <p style="font-size: 16px; margin-bottom: 10px;">Your Chosen Course: [' .

                        $selectedCourseList .

                        ']</p>

                            <p style="font-size: 16px; margin-top: 10px;">Do You Want To Register For IMU- CET Training? <a

                                    href="https://forms.gle/5Nmk3ydJnD4MwkMS6" target="_blank"

                                    style="text-decoration: none; color: white; background-color: #26528c; padding: 3px 7px ; border-radius: 5px;">YES</a>

                            </p>

                            <div style="display: flex; flex-direction:column; margin-top: 20px;">

                                <a href="https://wa.link/4w4det"

                                    style="padding: 10px 20px; background-color: #26528c; color: #ffffff; text-decoration: none; border-radius: 5px;">Whatsapp

                                    Maritime Studies</a>

                                <a href="https://wa.link/336b2x"

                                    style="padding: 10px 20px; background-color: #26528c; color: #ffffff; text-decoration: none; border-radius: 5px;">Whatsapp

                                    Engineering Studies</a>

                            </div>

                        </div>

                        <div style="background-color: #26528c; color: #ffffff; padding: 20px;">

                            <p style="font-size: 24px; margin-bottom: 10px;">Thanks for the support! ????</p>

                            <p style="font-size: 16px; margin-bottom: 10px;">College Location:<br>

                                82, Panapakkam, Near Periyapalayam, Chennai Thirupathi Road, Uthukottai, Taluk, Thiruvallur District, Near

                                Honda Factory, Chennai, Tamil Nadu 601102.</p>

                            <div style="display: flex; flex-direction:column;">

                                <p style="font-size: 16px;">Phone Number: <a href="tel:8925832436"

                                        style="color: #fbeeb8; text-decoration: underline;">8925832436</a></p>

                                <p style="font-size: 16px;">Email: <a href="mailto:[email protected]"

                                        style="color: #fbeeb8; text-decoration: underline;">[email protected]</a></p>

                            </div>

                        </div>

                    </body>                   

                    </html>                   

';



                    $mail->setFrom("[email protected]", "SAMS");

                    $mail->addAddress($email, $firstName);

                    $mail->Subject = "Application Confirmation";

                    $mail->Body = $htmlContent;

                    $mail->isHTML(true);

                    $mail->Body = $htmlContent;

                    $mail->ContentType = "text/html";



                    $mail->send();

                } catch (Exception $e) {

                    $errors[] =

                        "Email could not be sent. Mailer Error: " .

                        $mail->ErrorInfo;

                }



                header("Location: thankyou.html");

                exit();

            } else {

                throw new Exception("Error: " . $sql . "<br>" . $conn->error);

            }

        } catch (Exception $e) {

            $errors[] = $e->getMessage();

        }

    }

}



$conn->close();



if (!empty($errors)) {

    foreach ($errors as $error) {

        echo $error . "<br>";

    }

}

?>

New contributor

Bala Subramanian A is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật