MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 18.188.154.238
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/justpestcontrol.in/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/justpestcontrol.in/index-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'];
        // $subject = $_POST['subject'];
        $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 = "digitalsaleem12@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.";
                }
            } else {
                echo "Error";
            }
        }
    }
}
?>

<style>
    .with-errors{
        color:red;
    }
</style>
<div style="background-color: rgb(231, 231, 231);padding: 50px;" id="contact" class="section ">
		<div class="container">
			<div class="row">
				<div class="col-sm-12 col-md-12">
					<div class="section-title">
						<h3 class="lead">Contact Information</h3>
					</div>
				</div>
				
			</div>
			<div class="row">
				<div class="col-md-6">
					<div class="row">
						<div style="border-bottom: 1px solid rgb(211, 211, 211);" class="col">
							<h3>Address:</h3>
							<p><?php echo $datac['address'];?></p>
						</div>
						<div style="border-bottom: 1px solid rgb(211, 211, 211);" class="col">
							<h3>Contact Number:</h3>
							<p><a href="tel:<?php echo $datac['phone'];?>"><?php echo $datac['phone'];?></a></p>
						</div>
						<div class="col mt-3">
							<h3>Email:</h3>
							<p><a href="mailto:<?php echo $datac['email'];?>"><?php echo $datac['email'];?></a></p>
						</div>
					</div>
				</div>
				<div  id="enquiry" class="col-sm-6 col-md-6">
					<div  style="border-radius: 20px;" class="blok quotes">
						<div class="blok-title">
							<span>SCHEDULE</span> <br>A FREE INSPECTION
						</div>
						<form method="POST" action="<?php $_PHP_SELF?>" class="form-contact shake" >
							<div class="form-group">
								<input type="text" class="form-control" name="name" placeholder="Enter Name *" required="">
								<div class="help-block with-errors">
								    <?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="form-group">
								<input type="email" class="form-control" name="email" placeholder="Enter Email *" required="">
								<div class="help-block with-errors">
								     <?php if (isset($errors) && in_array("Email field is required.", $errors)) { ?>
                                        <p class="error">Email field is required.</p>
                                    <?php } ?>
								</div>
							</div>
							<div class="form-group">
								<input type="text" class="form-control" name="phone" placeholder="Enter Phone *" required="">
								<div class="help-block with-errors">
								    <?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="form-group">
								 <textarea class="form-control" rows="4" name="message" placeholder="Enter Your Message *" required=""></textarea>
								<div class="help-block with-errors"></div>
							</div>
							<div class="form-group">
								<div id="success"></div>
								<button type="submit" name="submit" class="btn btn-default disabled" style="pointer-events: all; cursor: pointer;">ASK A QUOTE</button>
							</div>
						</form>
						<!-- <div class="icon"><span class="fa fa-calendar"></span></div>	 -->
					</div>
				</div>
			</div>
		</div>
	</div>

MMCT - 2023