MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 13.59.134.65
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/ppcad7no/arelectricalcontrol.com/../leetcoaching.co.in/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/arelectricalcontrol.com/../leetcoaching.co.in/contact.php
<?php
    include_once('admin/config.php');
    
    function isAllowedMessage($message) {
        $allowedChars = '/^[a-zA-Z0-9,@. ]*$/';
        return preg_match($allowedChars, $message);
    }
    
    if ($_SERVER["REQUEST_METHOD"] === "POST") {
        if (isset($_POST['submit'])) {
            $name = $_POST['name'];
            $phone = $_POST['phone'];
            $email = $_POST['email'];
            $message = $_POST['message'];
            date_default_timezone_set("Asia/Kolkata");
            $currentTime = date("Y-m-d H:i:s");
            $errors = array();
    
            // Validate input
            if (empty($name)) {
                $errors[] = "Name field is required.";
            } elseif (!preg_match('/^[a-zA-Z ]+$/', $name)) {
                $errors[] = "Name can only contain alphabets.";
            }
    
            if (empty($email)) {
                $errors[] = "Email field is required.";
            } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                $errors[] = "Invalid email format.";
            }
    
            if (empty($phone)) {
                $errors[] = "Phone field is required.";
            } elseif (!preg_match('/^\d{10}$/', $phone)) {
                $errors[] = "Phone number should have exactly 10 digits.";
            }
    
            // Sanitize input
            $name = filter_var($name, FILTER_SANITIZE_STRING);
            $phone = filter_var($phone, FILTER_SANITIZE_NUMBER_INT);
            $email = filter_var($email, FILTER_SANITIZE_EMAIL);
            $message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
    
            // Check for potentially malicious content in the message
            if (!isAllowedMessage($message)) {
                $errors[] = "Your message contains potentially malicious content or disallowed characters.";
            }
    
    if (empty($errors)) {
        // Your existing code for successful submission
        $query = "INSERT INTO `tbl_queries` (`name`, `phone`, `email`, `message`, `datetime`) VALUES (?, ?, ?, ?, ?)";
        $stmt = mysqli_prepare($db, $query);
    
        if ($stmt) {
            mysqli_stmt_bind_param($stmt, "sssss", $name, $phone, $email, $message, $currentTime);
            $result = mysqli_stmt_execute($stmt);
            mysqli_stmt_close($stmt);
    
            if ($result) {
                // $to = "digitalsaleem12@gmail.com";
                $to = "spanishseekho24@gmail.com";
                $subject = "New Query Submitted";
                $emailMessage = "A new query has been submitted:\n\n";
                $emailMessage .= "Name: $name\n";
                $emailMessage .= "Phone: $phone\n";
                $emailMessage .= "Email: $email\n";
                $emailMessage .= "Message: $message\n";
                
                $headers = "From: $email";
                
                if (mail($to, $subject, $emailMessage, $headers)) {
                echo "<script>
                window.alert('Successfully Sent! We will contact you soon');
                window.location.href = '$wspath' + 'contact.html';
                </script>";
            } else {
               echo "Error sending email.";
                }
            } else {
                $errors[] = "Error in processing your request. Please try again later.";
            }
        } else {
            $errors[] = "Error in preparing the statement.";
        }
    } else {
        // Display validation errors in an alert
        echo "<script>
            var errorMessage = '";
        foreach ($errors as $error) {
            echo addslashes($error) . "\\n";
        }
        echo "';
            window.alert(errorMessage);
        </script>";
    }
        }
    }
?>

<!doctype html>
<html class="no-js" lang="zxx">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php include("top-link.php") ?>
    
    <title><?php echo $datacontact["site_pages_meta_title"];?></title>
    <meta name="description" content="<?php echo $datacontact["site_pages_meta_description"];?>">

<body>

    <?php include("header.php"); ?>
    
    <main>
        <div class="it-breadcrumb-area it-breadcrumb-bg" data-background="assets/img/breadcrumb/breadcrumb.jpg">
            <div class="container">
                <div class="row ">
                    <div class="col-md-12">
                        <div class="it-breadcrumb-content z-index-3 text-center">
                            <div class="it-breadcrumb-title-box">
                                <h1 class="it-breadcrumb-title">Contact us</h1>
                            </div>
                            <div class="it-breadcrumb-list-wrap">
                                <div class="it-breadcrumb-list">
                                    <span><a href="<?php echo $wspath;?>">home</a></span>
                                    <span class="dvdr">//</span>
                                    <span>Contact</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="it-contact__area pt-50 pb-50">
            <div class="container">
                <div class="it-contact__wrap fix z-index-3 p-relative">
                    <div class="it-contact__shape-1 d-none d-xl-block">
                        <img src="<?php echo $wspath;?>assets/img/contact/shape-2-1.png" alt>
                    </div>
                    <div class="row align-items-end">
                        <div class="col-xl-7">
                            <div class="it-contact__right-box">
                                <div class="it-contact__section-box pb-20">
                                    <h4 class="it-contact__title pb-15">Get in Touch</h4>
                                    <!--<p>Suspendisse ultrice gravida dictum fusce placerat <br>-->
                                    <!--    ultricies integer </p>-->
                                </div>
                                <div class="it-contact__content mb-55">
                                    <ul>
                                        <li>
                                            <div class="it-contact__list d-flex align-items-start">
                                                <div class="it-contact__icon">
                                                    <span><i class="fa-solid fa-location-dot"></i></span>
                                                </div>
                                                <div class="it-contact__text">
                                                    <span>Our Address</span>
                                                    <a href="#"><?php echo $data1["address"] ?></a>
                                                </div>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="it-contact__list d-flex align-items-start">
                                                <div class="it-contact__icon">
                                                    <span><i class="fa-solid fa-clock"></i></span>
                                                </div>
                                                <div class="it-contact__text">
                                                    <span>Email</span>
                                                    <a href="mailto:<?php echo $data1["email"] ?>"><?php echo $data1["email"] ?></a>
                                            
                                                </div>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="it-contact__list d-flex align-items-start">
                                                <div class="it-contact__icon">
                                                    <span><i class="fa-solid fa-phone phone"></i></span>
                                                </div>
                                                <div class="it-contact__text">
                                                    <span>contact</span>
                                                    <a href="tel:<?php echo $data1["phone"] ?>"><?php echo $data1["phone"] ?></a>
                                                    <!--<a href="mailto:spanishseekho24@gmail.com"><span class="__cf_email__">spanishseekho24@gmail.com</span></a>-->
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="it-contact__bottom-box d-flex align-items-center justify-content-between">
                                    <!--<div class="it-contact__scrool smooth">-->
                                    <!--    <a href="#it-newsletter"><i class="fa-solid fa-arrow-down"></i>Customer Care</a>-->
                                    <!--</div>-->
                                    <div class="it-footer-social">
                                        <a href="<?php echo $data["facebook_link"] ?>"><i class="fa-brands fa-facebook-f"></i></a>
                                        <a href="<?php echo $data["insta_link"] ?>"><i class="fa-brands fa-instagram"></i></a>
                                        <a href="<?php echo $data1['pinterest_link'];?>"><i class="fa-brands fa-pinterest-p"></i></a>
                                        <a href="<?php echo $data["twitter_link"] ?>"><i class="fa-brands fa-twitter"></i></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xl-5">
                            <div class="it-contact__form-box">
                                <form action="<?php $_PHP_SELF?>" method="POST">
                                    <div class="row">
                                        <div class="col-12 mb-25">
                                            <div class="it-contact-input-box">
                                                <label>Name*</label>
                                                <input type="text" placeholder="Name" name="name" required>
                                                <?php if (isset($errors) && in_array("Name field is required.", $errors)) { ?>
                                                    <p class="error">Name field is required.</p>
                                                <?php } elseif (isset($errors) && in_array("Name can only contain alphabets.", $errors)) { ?>
                                                    <p class="error">Name can only contain alphabets.</p>
                                                <?php } ?>
                                            </div>
                                        </div>
                                        <div class="col-12 mb-25">
                                            <div class="it-contact-input-box">
                                                <label>Email Address*</label>
                                                <input type="email" placeholder="Email" name="email" required>
                                                <?php if (isset($errors) && in_array("Email field is required.", $errors)) { ?>
                                                    <p class="error">Email field is required.</p>
                                                <?php } ?>
                                            </div>
                                        </div>
                                        <div class="col-12 mb-25">
                                            <div class="it-contact-input-box">
                                                <label>Phone*</label>
                                                <input type="text" placeholder="Phone" name="phone" minlength="10" maxlength="10" onkeypress="return isNumberKey(event)" pattern=".{10,10}" onpaste="return false;" required>
                                                <?php if (isset($errors) && in_array("Phone field is required.", $errors)) { ?>
                                                    <p class="error">Phone field is required.</p>
                                                <?php } elseif (isset($errors) && in_array("Phone number should have exactly 10 digits.", $errors)) { ?>
                                                    <p class="error">Phone number should have exactly 10 digits.</p>
                                                <?php } ?>
                                            </div>
                                        </div>
                                        
                                        <div class="col-12 mb-25">
                                            <div class="it-contact-textarea-box">
                                                <label>Message</label>
                                                <textarea placeholder="Message" name="message"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                    <button type="submit" name="submit" class="it-btn">
                                        <span>
                                            Send Message
                                            <svg width="17" height="14" viewBox="0 0 17 14" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                <path d="M11 1.24023L16 7.24023L11 13.2402" stroke="currentcolor" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round" />
                                                <path d="M1 7.24023H16" stroke="currentcolor" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round" />
                                            </svg>
                                        </span>
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <?php include("footer.php");?>
    
</body>

</html>

MMCT - 2023