prepare(" SELECT s.*, fr.id as round_id, fr.funding_goal, fr.funding_raised, fr.status as round_status FROM startups s LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active' WHERE s.id = ? "); $stmt->execute([$startupId]); $startup = $stmt->fetch(); if (!$startup) { die("Startup not found."); } if ($startup['round_status'] !== 'Active') { die("This startup does not have an active funding round."); } $error = ''; $success = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $amount = (float)($_POST['amount'] ?? 0); $investor_id = $_SESSION['user_id']; if ($amount <= 0) { $error = "Please enter a valid investment amount."; } else { db()->beginTransaction(); try { // 1. Create investment record // Note: We'll assume 1% equity for every £1000 for simplicity or use a formula // Actually let's look at the database schema for investments $equity_pct = 0.00; // Mock logic for equity $stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'approved')"); $stmt->execute([$startupId, $investor_id, $startup['round_id'], $amount, $equity_pct]); // 2. Update funding_rounds raised amount $stmt = db()->prepare("UPDATE funding_rounds SET funding_raised = funding_raised + ? WHERE id = ?"); $stmt->execute([$amount, $startup['round_id']]); // 3. Update startup total raised $stmt = db()->prepare("UPDATE startups SET funding_raised = funding_raised + ? WHERE id = ?"); $stmt->execute([$amount, $startupId]); db()->commit(); $success = "Investment of £" . number_format($amount) . " confirmed successfully!"; header("refresh:3;url=portfolio.php"); } catch (Exception $e) { db()->rollBack(); $error = "Error: " . $e->getMessage(); } } } $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?> Invest in <?= htmlspecialchars($startup['name']) ?> | <?= htmlspecialchars($platformName) ?>

Back

You are participating in the active funding round for this startup.

Funding Goal £
Already Raised £
Remaining £
Back to Startup Profile