38873-vm/start_funding.php
Flatlogic Bot 21f3fc7eab v2
2026-02-28 15:08:46 +00:00

90 lines
4.7 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'founder') {
header("Location: login.php");
exit;
}
require_once __DIR__ . '/db/config.php';
$error = '';
$success = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$description = trim($_POST['description'] ?? '');
$target = (float)($_POST['funding_target'] ?? 0);
$status = $_POST['status'] ?? 'public';
if (empty($name) || empty($description) || $target < 50) {
$error = "Please fill in all required fields. Minimum target is £50.";
} else {
$stmt = db()->prepare("INSERT INTO startups (name, description, founder_id, funding_target, status) VALUES (?, ?, ?, ?, ?)");
try {
$stmt->execute([$name, $description, $_SESSION['user_id'], $target, $status]);
$success = "Startup listed successfully! Your funding round is now active.";
header("refresh:2;url=dashboard.php");
} catch (PDOException $e) {
$error = "Database error: " . $e->getMessage();
}
}
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Start Funding Round — <?= htmlspecialchars($platformName) ?></title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body style="display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 40px 20px;">
<div class="card" style="width: 100%; max-width: 600px;">
<h2 style="margin-bottom: 10px;">List Your Startup</h2>
<p style="color: var(--text-secondary); margin-bottom: 30px;">Kickstart your project with micro-investments from peers.</p>
<?php if ($error): ?>
<div style="background: rgba(255, 0, 0, 0.1); border: 1px solid rgba(255, 0, 0, 0.3); color: #ff5555; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div style="background: rgba(0, 255, 0, 0.1); border: 1px solid rgba(0, 255, 0, 0.3); color: #55ff55; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
<?= htmlspecialchars($success) ?>
</div>
<?php else: ?>
<form method="POST">
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Startup Name</label>
<input type="text" name="name" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Description</label>
<textarea name="description" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff; height: 120px; resize: none;"></textarea>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Funding Target (£)</label>
<input type="number" name="funding_target" min="50" step="50" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
<span style="font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: block;">Min investment per user will be £50.</span>
</div>
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Listing Type</label>
<select name="status" style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
<option value="public">Public (Visible to all investors)</option>
<option value="private">Private (Invite-only)</option>
</select>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 15px;">Launch Funding Round</button>
</form>
<?php endif; ?>
</div>
</body>
</html>