prepare(" SELECT ps.*, p.project_name FROM project_selections ps INNER JOIN projects p ON ps.project_id = p.id WHERE ps.id = ? AND ps.client_id = ? "); $stmt->execute([$selection_id, $_SESSION['client_id']]); $selection = $stmt->fetch(); if (!$selection) { header('Location: projects-list.php'); exit; } $project_id = $selection['project_id']; // Load existing URLs $stmt = $pdo->prepare("SELECT url_type, url FROM selection_survey_urls WHERE selection_id = ?"); $stmt->execute([$selection_id]); $existing_urls = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); } else { // Get project details $stmt = $pdo->prepare("SELECT * FROM projects WHERE id = ? AND client_id = ?"); $stmt->execute([$project_id, $_SESSION['client_id']]); $project = $stmt->fetch(); if (!$project) { header('Location: projects-list.php'); exit; } // Get selections for this project $stmt = $pdo->prepare("SELECT id, selection_name FROM project_selections WHERE project_id = ? ORDER BY created_at DESC"); $stmt->execute([$project_id]); $selections = $stmt->fetchAll(); } } catch (Exception $e) { error_log("Survey URLs error: " . $e->getMessage()); die("Error loading page"); } // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { $pdo->beginTransaction(); $target_selection_id = (int)$_POST['selection_id']; $urls = $_POST['url'] ?? []; // Delete existing URLs for this selection $stmt = $pdo->prepare("DELETE FROM selection_survey_urls WHERE selection_id = ?"); $stmt->execute([$target_selection_id]); // Insert new URLs $stmt = $pdo->prepare(" INSERT INTO selection_survey_urls (selection_id, url_type, url) VALUES (?, ?, ?) "); foreach ($urls as $type => $url) { if (!empty(trim($url))) { $stmt->execute([$target_selection_id, $type, trim($url)]); } } // Log activity $stmt = $pdo->prepare(" INSERT INTO selection_activity_log (selection_id, action, description, performed_by) VALUES (?, ?, ?, ?) "); $stmt->execute([ $target_selection_id, 'survey_urls_updated', 'Survey URLs added/updated', $_SESSION['client_id'] ]); $pdo->commit(); header('Location: view-selection.php?id=' . $target_selection_id . '&success=1'); exit; } catch (Exception $e) { if ($pdo->inTransaction()) { $pdo->rollBack(); } error_log("Save URLs error: " . $e->getMessage()); $error = $e->getMessage(); } } include 'client-portal-header.php'; ?>

Add Survey URLs

Configure survey URLs for your selection(s)

Error:
Note: Please select a specific selection to add survey URLs.
Selection:

Survey URLs

Add URLs for different survey outcomes. These URLs will be used to redirect panel members based on their survey completion status.

Main Survey URL

Primary survey link where respondents will start
Use [UID] as placeholder for user ID

Complete URL

Redirect URL for successfully completed surveys

Screen Out URL

Redirect URL for respondents who don't qualify

Quota Full URL

Redirect URL when survey quota is reached

Over Quota URL

Redirect URL when respondent exceeds quota limits

Quality Termination URL

Redirect URL for quality-based terminations
Cancel