MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 18.190.153.77
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/aanuwoolenenterprises.com/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/aanuwoolenenterprises.com/contact.php
<?php
include_once('admin/config.php');

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

        if (empty($name)) {
            $errors[] = "Name field is required.";
        } elseif (!ctype_alpha($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); // Sanitize the message input
        }

        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 = "kumarimlesh1@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 .= "Address: $address\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.";
            }
        }
    }
}
}
?>
<!DOCTYPE html>
<html lang="zxx">
<head>
    <meta charset="UTF-8">
    <meta name="description" content="Fashi Template">
    <meta name="keywords" content="Fashi, unica, creative, html">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Annu Woolen Enterprise</title>
    <?php include 'top-link.php';?>
    
</head>

<body>
<?php include 'header.php';?>
<div class="breacrumb-section">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="breadcrumb-text">
                        <a href="index.php"><i class="fa fa-home"></i> Home</a>
                        <span>Contact</span>
                    </div>
                </div>
            </div>
        </div>
    </div>




    <section class="contact-section spad">
        <div class="container">
            <div class="row">
                <div class="col-lg-5">
                    <div class="contact-title">
                        <h4>Contacts Us</h4>
                    </div>
                    <div class="contact-widget">
                        <div class="cw-item">
                            <div class="ci-icon">
                                <i class="ti-location-pin"></i>
                            </div>
                            <div class="ci-text">
                                <span>Address:</span>
                                <p>6Ludhiyana, Punjab, India</p>
                            </div>
                        </div>
                        <div class="cw-item">
                            <div class="ci-icon">
                                <i class="ti-mobile"></i>
                            </div>
                            <div class="ci-text">
                                <span>Phone:</span>
                                <p>+91 988-8817-277</p>
                            </div>
                        </div>
                        <div class="cw-item">
                            <div class="ci-icon">
                                <i class="ti-email"></i>
                            </div>
                            <div class="ci-text">
                                <span>Email:</span>
                                <p><a style="color:black" href="mailto:kumarimlesh1@gmail.com"> kumarimlesh1@gmail.com</a>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6 offset-lg-1">
                    <div class="contact-form">
                        <div class="leave-comment">
                            <h4>Leave A Comment</h4>
                            <p>Our staff will call back later and answer your questions.</p>
                            <form action="<?php $_PHP_SELF?>" method="POST" class="comment-form">
                                <div class="row">
                                    <div class="col-lg-12">
                                        <input  name="name" type="text" 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 } ?>
                                    </div>
                                    <div class="col-lg-6">
                                        <input name="phone" type="text" placeholder="Phone" id="phone_no" minlength="10" maxlength="10" onkeypress="return isNumberKey(event)" pattern=".{10,10}" class="form-control" required="" 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 class="col-lg-6">
                                        <input name="email" type="text" placeholder="Your email">
                                        <?php if (isset($errors) && in_array("Email field is required.", $errors)) { ?>
                                            <p class="error">Email field is required.</p>
                                        <?php } ?>
                                    </div>
                                    
                                    <div class="col-lg-12">
                                        <textarea name="message" placeholder="Your message"></textarea>
                                        <input class="submit" type="submit" name="submit" value="Send Message">
                                    </div>
                                </div>
                           
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    

<?php include 'footer.php';?>
</body>
</html>

MMCT - 2023