MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.21.159.223
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/bestacservice.co.in/../pilingdrillingservices.com/../deergham.com/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/bestacservice.co.in/../pilingdrillingservices.com/../deergham.com/contact.php
<?php
    session_start();
    include_once('admin/config.php');

if ($_SERVER["REQUEST_METHOD"] === "POST") {
    if (isset($_POST['submit-1'])) {
        $name = $_POST['name'];
        $phone = $_POST['phone'];
        $email = $_POST['email'];
        $message = $_POST['message'];

        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.";
        }

        if (empty($phone)) {
            $errors[] = "Phone field is required.";
        } elseif (!preg_match('/^\d{10}$/', $phone)) {
            $errors[] = "Phone number should have exactly 10 digits.";
        }
        if (!empty($message)) {
            $message = htmlspecialchars($message); 
        }

        if (empty($errors)) {
            $query = "INSERT INTO `tbl_queries` (`name`, `phone`, `email`, `message`) VALUES (?, ?, ?, ?)";
            $stmt = mysqli_prepare($db, $query);
            mysqli_stmt_bind_param($stmt, "ssss", $name, $phone, $email, $message);
            $result = mysqli_stmt_execute($stmt);
            mysqli_stmt_close($stmt);

            if ($result) {
                // Sending email
                // $to = "digitalsaleem12@gmail.com";
                $to ="kartar93singh.04@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 = 'contact.html';
                </script>";
            } else {
               echo "Error sending email.";
                }
            } else {
              echo "Error";
            }
       }
   }
 }
?>
<!DOCTYPE html>
<html lang=en>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <?php include "top-links.php" ?>
    
    <title><?= $datahome['site_pages_meta_title'] ?></title>
    <meta name="description" content="<?= $datahome['site_pages_meta_description'] ?>">
    <link rel="stylesheet" href="<?php echo $wspath?>css/contacts.min.css">
    <style>
        .error{
            color:red;
        }
    </style>
</head>

<body>
    <?php include "header.php" ?>
   
    <main>
    <header class="page" style="padding-top:;">
        <div class="page_main container-fluid">
            <div class="container">
                <h1 class="page_header">Contact</h1>
                <!--<p class="page_text">Nibh tellus molestie nunc non blandit. Mi tempus imperdiet nulla malesuada-->
                <!--    pellentesque elit</p>-->
            </div>
        </div>
        <div class="container">
            <ul class="page_breadcrumbs d-flex flex-wrap">
                <li class="page_breadcrumbs-item"><a class="link" href="<?php echo $wspath?>">Home</a></li>
                <li class="page_breadcrumbs-item current"><span>Contact</span></li>
            </ul>
        </div>
    </header>
        <div class="contacts section">
            <div class="container d-flex flex-wrap flex-xl-nowrap justify-content-between">
                <div class=" col-12 col-lg-6">
                    <div class=contacts_form-header>
                        <h2 class=contacts_form-header_title>Have any Questions?</h2>
                        <!--<p class=contacts_form-header_text>Elementum eu facilisis sed odio morbi quis commodo odio.-->
                        <!--    Mauris rhoncus aenean vel elit scelerisque mauris pellentesque</p>-->
                    </div>
                    <form class="contacts_form-form d-flex flex-column" action="<?php $_PHP_SELF?>" method="POST">
                        <label class=contacts_form-form_label for="contactsName">Your Name</label>
                        <input class="contacts_form-form_field field" type="text" name="name" placeholder="Your name">
                        <?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 } ?>
                        <label class=contacts_form-form_label for="contactsEmail">Your Mobile</label> 
                        <input class="contacts_form-form_field field " type="text" name="phone" placeholder="Mobile Number" 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 } ?>
                        
                        <label class=contacts_form-form_label for="contactsEmail">Your Email</label> 
                        <input class="contacts_form-form_field field " type="email" name="email" placeholder="you@example.com"> 
                        <?php if (isset($errors) && in_array("Email field is required.", $errors)) { ?>
                            <p class="error">Email field is required.</p>
                        <?php } ?>
                        <label class=contacts_form-form_label for="contactsMessage">Message</label> 
                        <textarea class="contacts_form-form_field field " name="message" placeholder="Type Your Message"></textarea>
                        
                        <button class="btn" name="submit-1" type="submit">Send a Message</button>
                    </form>
                </div>
                <div class="contacts_info col-12 col-lg-6 flex-xl-grow-1 pt-5">
                    <!--<div class=contacts_info-map>-->
                    <!--    <div id=map></div>-->
                    <!--</div>-->
                    <ul class=contacts_info-list>
                        <li class="contacts_info-list_item d-flex flex-column flex-sm-row align-items-center">
                            <span class="icon d-flex justify-content-center align-items-center"><i class=icon-location></i></span>
                            <div class="main d-flex flex-column"><span><?php echo $data1['address'];?></span>
                            </div>
                        </li>
                        <li class="contacts_info-list_item d-flex flex-column flex-sm-row align-items-center">
                            <span class="icon d-flex justify-content-center align-items-center"><i class=icon-call></i></span>
                            <div class="main d-flex flex-column">
                                <a class="link" href="tel:<?php echo $data1['phone'];?>"><?php echo $data1['phone'];?></a>
                                <!--<a class=link href=tel:+1234567890>+1-896-882-3255</a>-->
                            </div>
                        </li>
                        <li class="contacts_info-list_item d-flex flex-column flex-sm-row align-items-center">
                            <span class="icon d-flex justify-content-center align-items-center"><i class=icon-envelope_open></i></span>
                            <div class="main d-flex flex-column">
                                <a class="link" href="mailto:<?php echo $data1['email'];?>"><?php echo $data1['email'];?></a>
                                <!--<a class=link href=mailto:example@domain.com>herbalist@test.site</a>-->
                            </div>
                        </li>
                    </ul>
                    <ul class="contacts_info-socials d-flex align-items-center justify-content-center justify-content-sm-start">
                        <li class="list-item"><a class="link" href="<?php echo $data1['facebook_link'];?>" target="_blank" rel="noopener norefferer"><i class="icon-facebook icon"></i></a></li>
                        <li class="list-item"><a class="link" href="<?php echo $data1['insta_link'];?>" target="_blank" rel="noopener norefferer"><i class="icon-instagram icon"></i></a></li>
                        <li class="list-item"><a class="link" href="<?php echo $data1['twitter_link'];?>" target="_blank" rel="noopener norefferer"><i class="icon-twitter icon"></i></a></li>
                        <li class="list-item"><a class="link" href="https://wa.me/<?php echo $data1['whatsapp'];?>" target="_blank" rel="noopener norefferer"><i class="icon-whatsapp icon"></i></a></li>
                    </ul>
                </div>
                
            </div>
        </div>
    </main>
    
    <?php include "footer.php" ?>
</body>

</html>

MMCT - 2023