diff --git a/assets/js/main.js b/assets/js/main.js index 8ff3ac2..260453c 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,64 +1,71 @@ document.addEventListener('DOMContentLoaded', function() { - const steps = document.querySelectorAll('.form-step'); - const nextButtons = document.querySelectorAll('.btn-next'); - const prevButtons = document.querySelectorAll('.btn-prev'); - const progressBar = document.querySelector('.progress-bar'); const form = document.getElementById('gtm-form'); - let currentStep = 0; + if (form) { + const steps = document.querySelectorAll('.form-step'); + const nextButtons = document.querySelectorAll('.btn-next'); + const prevButtons = document.querySelectorAll('.btn-prev'); + const progressBar = document.querySelector('.progress-bar'); - function updateProgress() { - const progress = ((currentStep + 1) / steps.length) * 100; - progressBar.style.width = progress + '%'; - progressBar.setAttribute('aria-valuenow', progress); + let currentStep = 0; + + function updateProgress() { + if (progressBar) { + const progress = ((currentStep + 1) / steps.length) * 100; + progressBar.style.width = progress + '%'; + progressBar.setAttribute('aria-valuenow', progress); + } + } + + function showStep(stepIndex) { + steps.forEach((step, index) => { + step.classList.toggle('active', index === stepIndex); + }); + currentStep = stepIndex; + updateProgress(); + } + + nextButtons.forEach(button => { + button.addEventListener('click', () => { + if (currentStep < steps.length - 1) { + showStep(currentStep + 1); + } + }); + }); + + prevButtons.forEach(button => { + button.addEventListener('click', () => { + if (currentStep > 0) { + showStep(currentStep - 1); + } + }); + }); + + form.addEventListener('submit', function(e) { + e.preventDefault(); + const formData = new FormData(form); + + fetch('submit_profile.php', { + method: 'POST', + body: formData + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + window.location.href = 'profile.php?id=' + data.profile_id; + } else { + alert('An error occurred: ' + data.error); + } + }) + .catch(error => { + console.error('Error:', error); + alert('A network error occurred. Please try again.'); + }); + }); + + if(steps.length > 0) { + showStep(0); + } } - - function showStep(stepIndex) { - steps.forEach((step, index) => { - step.classList.toggle('active', index === stepIndex); - }); - currentStep = stepIndex; - updateProgress(); - } - - nextButtons.forEach(button => { - button.addEventListener('click', () => { - if (currentStep < steps.length - 1) { - showStep(currentStep + 1); - } - }); - }); - - prevButtons.forEach(button => { - button.addEventListener('click', () => { - if (currentStep > 0) { - showStep(currentStep - 1); - } - }); - }); - - form.addEventListener('submit', function(e) { - e.preventDefault(); - const formData = new FormData(form); - - fetch('submit_profile.php', { - method: 'POST', - body: formData - }) - .then(response => response.json()) - .then(data => { - if (data.success) { - document.getElementById('form-container').innerHTML = '
Thank you! Your GTM profile has been submitted.
'; - } else { - alert('An error occurred: ' + data.error); - } - }) - .catch(error => { - console.error('Error:', error); - alert('A network error occurred. Please try again.'); - }); - }); - - showStep(0); }); diff --git a/assets/pasted-20251003-180728-e982398f.png b/assets/pasted-20251003-180728-e982398f.png new file mode 100644 index 0000000..52c61ab Binary files /dev/null and b/assets/pasted-20251003-180728-e982398f.png differ diff --git a/assets/pasted-20251003-182128-a1c67c6d.png b/assets/pasted-20251003-182128-a1c67c6d.png new file mode 100644 index 0000000..f0564b7 Binary files /dev/null and b/assets/pasted-20251003-182128-a1c67c6d.png differ diff --git a/form_submission.log b/form_submission.log new file mode 100644 index 0000000..e69de29 diff --git a/index.php b/index.php index b678297..0fec9c8 100644 --- a/index.php +++ b/index.php @@ -60,8 +60,8 @@

GTM Maximizer

AI Powered Solutions Generating Profitable and Efficient Revenue and Customer Growth

Build New Process and Organization - Existing Process - Existing Organization + Existing Process + Existing Organization diff --git a/list_profiles.php b/list_profiles.php new file mode 100644 index 0000000..e885e15 --- /dev/null +++ b/list_profiles.php @@ -0,0 +1,86 @@ +query("SELECT id, business_name, sells_what, created_at FROM gtm_profiles ORDER BY created_at DESC"); + $profiles = $stmt->fetchAll(PDO::FETCH_ASSOC); +} catch (PDOException $e) { + // Handle database connection error + error_log($e->getMessage()); +} + +?> + + + + + + Existing GTM Profiles + + + + + + + + + + +
+

Existing GTM Profiles

+ +
+
+ + + + + + + + + + + + + + + + + + + +
Business NameSells WhatCreated AtAction
View
+
+
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/profile.php b/profile.php index 086d80b..3a052f2 100644 --- a/profile.php +++ b/profile.php @@ -2,13 +2,17 @@ require_once 'db/config.php'; $profile = null; -try { - $pdo = db(); - $stmt = $pdo->query("SELECT * FROM gtm_profiles ORDER BY created_at DESC LIMIT 1"); - $profile = $stmt->fetch(PDO::FETCH_ASSOC); -} catch (PDOException $e) { - // Handle database connection error - error_log($e->getMessage()); +$profile_id = $_GET['id'] ?? null; + +if ($profile_id) { + try { + $pdo = db(); + $stmt = $pdo->prepare("SELECT * FROM gtm_profiles WHERE id = ?"); + $stmt->execute([$profile_id]); + $profile = $stmt->fetch(PDO::FETCH_ASSOC); + } catch (PDOException $e) { + error_log($e->getMessage()); + } } ?> @@ -67,7 +71,7 @@ try {
Business Name:
-

What we sell:

+

Sells What:


Market & Sales

Ideal Customer Profile (ICP):

@@ -84,7 +88,7 @@ try {
@@ -96,4 +100,4 @@ try { - + \ No newline at end of file diff --git a/start.php b/start.php index 4bcdd75..0e83df5 100644 --- a/start.php +++ b/start.php @@ -68,7 +68,7 @@
-
+

Business Information

diff --git a/submit_profile.php b/submit_profile.php index 455996f..c8283e8 100644 --- a/submit_profile.php +++ b/submit_profile.php @@ -21,12 +21,14 @@ try { $_POST['market_size'] ?? '', implode(', ', $_POST['sales_motions'] ?? []), $_POST['org_size'] ?? '', - implode(', ', $_POST['roles'] ?? []), + $_POST['roles'] ?? '', $_POST['goals'] ?? '' ]); - echo json_encode(['success' => true]); + $last_id = $pdo->lastInsertId(); + + echo json_encode(['success' => true, 'profile_id' => $last_id]); } catch (PDOException $e) { // In a real app, you would log this error, not expose it to the user. echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]); -} +} \ No newline at end of file