diff --git a/.recaptcha-config.php b/.recaptcha-config.php
index f7309bb..18a5f4d 100644
--- a/.recaptcha-config.php
+++ b/.recaptcha-config.php
@@ -1,7 +1,7 @@
diff --git a/assets/js/main.js b/assets/js/main.js
index 58fd5c3..a31fcbb 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -171,6 +171,21 @@ document.addEventListener('DOMContentLoaded', function() {
console.log('Enhanced animations initialized');
+ // Initialize reCAPTCHA and form tracking
+ let interactionScore = 0;
+ let formStartTime = Date.now();
+
+ // Track user interactions for bot detection
+ document.addEventListener('mousemove', () => interactionScore += 1);
+ document.addEventListener('keydown', () => interactionScore += 2);
+ document.addEventListener('click', () => interactionScore += 3);
+
+ // Set form timestamp
+ const timestampField = document.getElementById('form_timestamp');
+ if (timestampField) {
+ timestampField.value = formStartTime;
+ }
+
// Form Validation and Enhancement
const contactForm = document.querySelector('.contact-form form');
@@ -210,28 +225,47 @@ document.addEventListener('DOMContentLoaded', function() {
submitButton.textContent = 'Sending...';
submitButton.disabled = true;
- // Submit form (you'll need to implement the backend handler)
- fetch('contact-handler.php', {
- method: 'POST',
- body: formData
- })
- .then(response => response.json())
- .then(data => {
- if (data.success) {
- showNotification('Message sent successfully! We\'ll get back to you soon.', 'success');
- this.reset();
- } else {
- showNotification('There was an error sending your message. Please try again.', 'error');
- }
- })
- .catch(error => {
- console.error('Error:', error);
- showNotification('There was an error sending your message. Please try again.', 'error');
- })
- .finally(() => {
+ // Execute reCAPTCHA and submit form
+ if (typeof grecaptcha !== 'undefined') {
+ grecaptcha.ready(() => {
+ grecaptcha.execute(window.recaptchaSiteKey, {action: 'contact_form'}).then((token) => {
+ // Add reCAPTCHA token and interaction data
+ formData.set('recaptcha_response', token);
+ formData.set('interaction_token', btoa(JSON.stringify({score: Math.min(interactionScore, 100), time: Date.now() - formStartTime})));
+
+ // Submit form
+ fetch('contact-handler.php', {
+ method: 'POST',
+ headers: {
+ 'X-Requested-With': 'XMLHttpRequest'
+ },
+ body: formData
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ showNotification('Message sent successfully! We\'ll get back to you soon.', 'success');
+ this.reset();
+ } else {
+ showNotification(data.message || 'There was an error sending your message. Please try again.', 'error');
+ }
+ })
+ .catch(error => {
+ console.error('Error:', error);
+ showNotification('There was an error sending your message. Please try again.', 'error');
+ })
+ .finally(() => {
+ submitButton.textContent = originalText;
+ submitButton.disabled = false;
+ });
+ });
+ });
+ } else {
+ // Fallback if reCAPTCHA not loaded
+ showNotification('Security verification not available. Please refresh the page.', 'error');
submitButton.textContent = originalText;
submitButton.disabled = false;
- });
+ }
} else {
showNotification(errors.join('
'), 'error');
}
diff --git a/contact-handler.php b/contact-handler.php
index ff7b96b..a04c803 100644
--- a/contact-handler.php
+++ b/contact-handler.php
@@ -2,6 +2,8 @@
// Enhanced Contact Form Handler with Security
session_start();
+// Form handler restored - temporary fix removed
+
// Include reCAPTCHA config
require_once '.recaptcha-config.php';
diff --git a/index.php b/index.php
index 6b2d329..1a50920 100644
--- a/index.php
+++ b/index.php
@@ -91,6 +91,11 @@ $twitter_card_image = "https://ukdataservices.co.uk/assets/images/ukds-main-logo
-->
+
+
+
+
+
@@ -99,7 +104,7 @@ $twitter_card_image = "https://ukdataservices.co.uk/assets/images/ukds-main-logo
-
+