diff --git a/create_startup.php b/create_startup.php index ff2ff65..42863e5 100644 --- a/create_startup.php +++ b/create_startup.php @@ -1,50 +1,53 @@ 0) { +if ($startup_id) { $stmt = db()->prepare("SELECT * FROM startups WHERE id = ? AND founder_id = ?"); $stmt->execute([$startup_id, $_SESSION['user_id']]); $existingStartup = $stmt->fetch(); + if (!$existingStartup) { + header('Location: dashboard.php'); + exit; + } } if ($_SERVER['REQUEST_METHOD'] === 'POST') { - // Basic Info - $name = trim($_POST['name'] ?? ''); - $legal_name = trim($_POST['legal_name'] ?? ''); - $country = trim($_POST['country'] ?? ''); - $industry = trim($_POST['industry'] ?? ''); - $sub_industry = trim($_POST['sub_industry'] ?? ''); - $business_model = trim($_POST['business_model'] ?? ''); - $product_service = trim($_POST['product_service'] ?? ''); - $operational_stage = trim($_POST['operational_stage'] ?? ''); + $name = $_POST['name'] ?? ''; + $legal_name = $_POST['legal_name'] ?? ''; + $country = $_POST['country'] ?? ''; + $industry = $_POST['industry'] ?? ''; + $sub_industry = $_POST['sub_industry'] ?? ''; + $business_model = $_POST['business_model'] ?? ''; + $product_service = $_POST['product_service'] ?? ''; + $operational_stage = $_POST['operational_stage'] ?? ''; + + // Co-founder matching fields + $cofounder_equity_pct = $_POST['cofounder_equity_pct'] ?? ''; + $cofounder_equity_type = $_POST['cofounder_equity_type'] ?? ''; + $cofounder_responsibilities = $_POST['cofounder_responsibilities'] ?? ''; + $desired_cofounder_experience = $_POST['desired_cofounder_experience'] ?? ''; + $cofounder_commitment = $_POST['cofounder_commitment'] ?? ''; + $other_partnership_details = $_POST['other_partnership_details'] ?? ''; - // Co-founder Matching - $cofounder_equity_pct = trim($_POST['cofounder_equity_pct'] ?? ''); - $cofounder_equity_type = trim($_POST['cofounder_equity_type'] ?? ''); - $cofounder_responsibilities = trim($_POST['cofounder_responsibilities'] ?? ''); - $desired_cofounder_experience = trim($_POST['desired_cofounder_experience'] ?? ''); - $cofounder_commitment = trim($_POST['cofounder_commitment'] ?? ''); - $other_partnership_details = trim($_POST['other_partnership_details'] ?? ''); - - // Current Financials + // Financial stats $current_cash_balance = (float)($_POST['current_cash_balance'] ?? 0); - $outstanding_debt = trim($_POST['outstanding_debt'] ?? ''); - $accounts_receivable_payable = trim($_POST['accounts_receivable_payable'] ?? ''); $burn_rate = (float)($_POST['burn_rate'] ?? 0); + $outstanding_debt = $_POST['outstanding_debt'] ?? ''; + $accounts_receivable_payable = $_POST['accounts_receivable_payable'] ?? ''; - // File Uploads $upload_dir = 'assets/docs/financials/'; if (!is_dir($upload_dir)) { mkdir($upload_dir, 0775, true); @@ -55,8 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'doc_balance_sheets', 'doc_cash_flow_statements', 'doc_revenue_breakdown', - 'doc_gross_margin', - 'doc_opex_breakdown' + 'doc_gross_margin' ]; $uploaded_paths = []; @@ -120,7 +122,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { name = ?, legal_name = ?, country = ?, industry = ?, sub_industry = ?, business_model = ?, product_service = ?, operational_stage = ?, cofounder_equity_pct = ?, cofounder_equity_type = ?, cofounder_responsibilities = ?, desired_cofounder_experience = ?, cofounder_commitment = ?, other_partnership_details = ?, current_cash_balance = ?, outstanding_debt = ?, accounts_receivable_payable = ?, burn_rate = ?, - doc_income_statements = ?, doc_balance_sheets = ?, doc_cash_flow_statements = ?, doc_revenue_breakdown = ?, doc_gross_margin = ?, doc_opex_breakdown = ?, + doc_income_statements = ?, doc_balance_sheets = ?, doc_cash_flow_statements = ?, doc_revenue_breakdown = ?, doc_gross_margin = ?, recommended_return_rate = ? WHERE id = ? AND founder_id = ?"); @@ -129,7 +131,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $cofounder_equity_pct, $cofounder_equity_type, $cofounder_responsibilities, $desired_cofounder_experience, $cofounder_commitment, $other_partnership_details, $current_cash_balance, $outstanding_debt, $accounts_receivable_payable, $burn_rate, $uploaded_paths['doc_income_statements'], $uploaded_paths['doc_balance_sheets'], $uploaded_paths['doc_cash_flow_statements'], - $uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'], $uploaded_paths['doc_opex_breakdown'], + $uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'], $recommended_return_rate, $existingStartup['id'], $_SESSION['user_id'] ]); $final_id = $existingStartup['id']; @@ -138,16 +140,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { name, legal_name, country, industry, sub_industry, business_model, product_service, operational_stage, cofounder_equity_pct, cofounder_equity_type, cofounder_responsibilities, desired_cofounder_experience, cofounder_commitment, other_partnership_details, current_cash_balance, outstanding_debt, accounts_receivable_payable, burn_rate, - doc_income_statements, doc_balance_sheets, doc_cash_flow_statements, doc_revenue_breakdown, doc_gross_margin, doc_opex_breakdown, + doc_income_statements, doc_balance_sheets, doc_cash_flow_statements, doc_revenue_breakdown, doc_gross_margin, founder_id, recommended_return_rate, status - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'private')"); + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'private')"); $stmt->execute([ $name, $legal_name, $country, $industry, $sub_industry, $business_model, $product_service, $operational_stage, $cofounder_equity_pct, $cofounder_equity_type, $cofounder_responsibilities, $desired_cofounder_experience, $cofounder_commitment, $other_partnership_details, $current_cash_balance, $outstanding_debt, $accounts_receivable_payable, $burn_rate, $uploaded_paths['doc_income_statements'], $uploaded_paths['doc_balance_sheets'], $uploaded_paths['doc_cash_flow_statements'], - $uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'], $uploaded_paths['doc_opex_breakdown'], + $uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'], $_SESSION['user_id'], $recommended_return_rate ]); $final_id = db()->lastInsertId(); @@ -155,99 +157,108 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { db()->commit(); $success = "Startup profile saved successfully! Recommended return rate: " . number_format($recommended_return_rate, 2) . "%"; - header("refresh:2;url=startup_details.php?id=" . $final_id); + + // Refresh local data + $stmt = db()->prepare("SELECT * FROM startups WHERE id = ?"); + $stmt->execute([$final_id]); + $existingStartup = $stmt->fetch(); + } catch (Exception $e) { db()->rollBack(); - $error = "Error: " . $e->getMessage(); + $error = "Database error: " . $e->getMessage(); } } } - -$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?> - +
- - -- = $existingStartup ? 'Update your venture details below.' : 'This information is required to establish your startup entity and calculate investor return projections.' ?> -
+